From b0fd7e1f65049b7efdf50febe6765039de4289ed Mon Sep 17 00:00:00 2001
From: Patrick Griffis <pgriffis@igalia.com>
Date: Wed, 16 Dec 2020 15:54:32 -0600
Subject: [PATCH] Handle sniffing bytes with 0 size

---
 libsoup/soup-content-sniffer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libsoup/soup-content-sniffer.c b/libsoup/soup-content-sniffer.c
index cb4255ade..cf5da7e1f 100644
--- a/libsoup/soup-content-sniffer.c
+++ b/libsoup/soup-content-sniffer.c
@@ -507,6 +507,9 @@ sniff_unknown (SoupContentSniffer *sniffer, GBytes *buffer,
 	guint resource_length = MIN (512, buffer->length);
 	guint i;
 
+        if (resource_length == 0)
+                return g_strdup ("application/octet-stream");
+
 	for (i = 0; i < G_N_ELEMENTS (types_table); i++) {
 		SoupContentSnifferPattern *type_row = &(types_table[i]);
 
-- 
GitLab
