]> sjero.net Git - wget/commitdiff
[svn] Fix potential memory leak in request_set_header.
authorhniksic <devnull@localhost>
Sun, 17 Apr 2005 16:59:35 +0000 (09:59 -0700)
committerhniksic <devnull@localhost>
Sun, 17 Apr 2005 16:59:35 +0000 (09:59 -0700)
src/ChangeLog
src/http.c

index eccdebb2fa9f0e0d8fd9334760dbb3c5599c3755..c0dd819f1f0a359af44e0e80c4fac8c7c9e7ad3c 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-17  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * http.c (request_set_header): Free NAME when VALUE is NULL and
+       freeing the header name is requested.
+
 2005-04-17  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * snprintf.c (fmtstr): Declare VALUE as const char *.
index fd7ff440193c00dd7648b04e8643212b7584f90e..c54eadf499bf92e02785cf1ef462f95159a9d9d4 100644 (file)
@@ -234,7 +234,13 @@ request_set_header (struct request *req, char *name, char *value,
   struct request_header *hdr;
   int i;
   if (!value)
-    return;
+    {
+      /* A NULL value is a no-op; if freeing the name is requested,
+        free it now to avoid leaks.  */
+      if (release_policy == rel_name || release_policy == rel_both)
+       xfree (name);
+      return;
+    }
   for (i = 0; i < req->hcount; i++)
     {
       hdr = &req->headers[i];