gresource: Fix handling of zero-sized compressed resource entries

The zlib `GConverter` can’t handle an output buffer of size 0.

Add tests.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #1560
This commit is contained in:
Philip Withnall
2020-11-14 19:02:31 +00:00
parent 1c290acd74
commit 353020928c
4 changed files with 71 additions and 1 deletions

View File

@@ -800,7 +800,9 @@ g_resource_lookup_data (GResource *resource,
if (!do_lookup (resource, path, lookup_flags, &size, &flags, &data, &data_size, error))
return NULL;
if (flags & G_RESOURCE_FLAGS_COMPRESSED)
if (size == 0)
return g_bytes_new_with_free_func ("", 0, (GDestroyNotify) g_resource_unref, g_resource_ref (resource));
else if (flags & G_RESOURCE_FLAGS_COMPRESSED)
{
char *uncompressed, *d;
const char *s;