After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 709794 - libsoup memory leak
libsoup memory leak
Status: RESOLVED DUPLICATE of bug 709793
Product: libsoup
Classification: Core
Component: Misc
2.42.x
Other All
: Normal normal
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2013-10-10 07:53 UTC by Ted
Modified: 2013-10-10 13:15 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ted 2013-10-10 07:53:38 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 == '%') {
Comment 1 Dan Winship 2013-10-10 13:15:27 UTC

*** This bug has been marked as a duplicate of bug 709793 ***