diff options
author | Patrick Griffis <pgriffis@igalia.com> | 2020-12-15 17:42:57 -0600 |
---|---|---|
committer | Patrick Griffis <pgriffis@igalia.com> | 2020-12-16 13:36:06 -0600 |
commit | e9c479728076229bbab57042ba198fbf25043816 (patch) | |
tree | fe18c4b93d172e369ea272f2f49fa310e0aa8576 | |
parent | 46969e196a1b29120c5ae1fefa83df0152274e7b (diff) | |
download | libsoup-e9c479728076229bbab57042ba198fbf25043816.tar.gz |
Fix minor issue found by fuzzing
-rw-r--r-- | libsoup/soup-uri-utils.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libsoup/soup-uri-utils.c b/libsoup/soup-uri-utils.c index dc1afd23..a39bb24d 100644 --- a/libsoup/soup-uri-utils.c +++ b/libsoup/soup-uri-utils.c @@ -344,11 +344,15 @@ soup_uri_decode_data_uri (const char *uri, bytes = g_uri_unescape_bytes (start, -1, NULL, NULL); if (base64 && bytes) { - gsize content_length; - GByteArray *unescaped_array = g_bytes_unref_to_array (bytes); - g_base64_decode_inplace ((gchar*)unescaped_array->data, &content_length); - unescaped_array->len = content_length; - bytes = g_byte_array_free_to_bytes (unescaped_array); + if (g_bytes_get_size (bytes) <= 1) + g_clear_pointer (&bytes, g_bytes_unref); + else { + gsize content_length; + GByteArray *unescaped_array = g_bytes_unref_to_array (bytes); + g_base64_decode_inplace ((gchar*)unescaped_array->data, &content_length); + unescaped_array->len = content_length; + bytes = g_byte_array_free_to_bytes (unescaped_array); + } } } else { bytes = g_bytes_new_static (NULL, 0); |