GNOME Bugzilla – Bug 709794
libsoup memory leak
Last modified: 2013-10-10 13:15:27 UTC
1. Assigning: "decoded" = storage returned from "g_strndup(part, length)" 2. leaked_storage: Variable "decoded" going out of scope leaks the storage it points to. uri_decoded_copy (const char *part, int length, int *decoded_length) { unsigned char *s, *d; char *decoded = g_strndup (part, length); g_return_val_if_fail (part != NULL, NULL); <== memory issue s = d = (unsigned char *)decoded; .... return decoded; } ------------------------ patch option 1 -------------------------- --- a/libsoup/soup-uri.c +++ b/libsoup/soup-uri.c @@ -724,7 +724,7 @@ uri_decoded_copy (const char *part, int length, int *decoded_length) unsigned char *s, *d; char *decoded = g_strndup (part, length); - g_return_val_if_fail (part != NULL, NULL); + g_return_val_if_fail (decoded != NULL, NULL); s = d = (unsigned char *)decoded; do { ------------------------ patch option 2 -------------------------- --- a/libsoup/soup-uri.c +++ b/libsoup/soup-uri.c @@ -722,10 +722,13 @@ char * uri_decoded_copy (const char *part, int length, int *decoded_length) { unsigned char *s, *d; - char *decoded = g_strndup (part, length); g_return_val_if_fail (part != NULL, NULL); + char *decoded = g_strndup (part, length); + + g_return_val_if_fail (decoded != NULL, NULL); + s = d = (unsigned char *)decoded; do { if (*s == '%') {
*** This bug has been marked as a duplicate of bug 709793 ***