gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35864 - in libmicrohttpd: . src/microhttpd


From: gnunet
Subject: [GNUnet-SVN] r35864 - in libmicrohttpd: . src/microhttpd
Date: Thu, 4 Jun 2015 13:37:05 +0200

Author: grothoff
Date: 2015-06-04 13:37:05 +0200 (Thu, 04 Jun 2015)
New Revision: 35864

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/src/microhttpd/digestauth.c
Log:
I was checking a test app in valgrind and much to my surprise it was 
complaining about a memleak in libmicrohttpd.
In check_argument_match() a buffer is allocated using strdup() but freed 
nowhere.

I wouldn't have noticed this leak if it wasn't for valgrind because if a URI is 
requested without any arguments (my usual case)
the buffer that gets allocated has 'only' a length of 1 byte, thus memory usage 
will build up very slowly over time.

The patch attached fixes it.
Btw. the indentation of that file is a mess, tabs and spaces are mixed :-|

Regards,
Andreas




Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2015-06-03 21:29:38 UTC (rev 35863)
+++ libmicrohttpd/ChangeLog     2015-06-04 11:37:05 UTC (rev 35864)
@@ -1,3 +1,6 @@
+Thu Jun  4 13:37:05 CEST 2015
+       Fixing memory leak in digest authentication. -AW
+
 Wed Jun 03 21:23:47 CEST 2015
        Add deprecation compiler messages for deprecated functions 
        and macros. -EG

Modified: libmicrohttpd/src/microhttpd/digestauth.c
===================================================================
--- libmicrohttpd/src/microhttpd/digestauth.c   2015-06-03 21:29:38 UTC (rev 
35863)
+++ libmicrohttpd/src/microhttpd/digestauth.c   2015-06-04 11:37:05 UTC (rev 
35864)
@@ -508,7 +508,10 @@
                                                 connection,
                                                 argp);
          if (MHD_YES != test_header (connection, argp, NULL))
-           return MHD_NO;
+      {
+        free(argb);
+        return MHD_NO;
+      }
          num_headers++;
          break;
        }
@@ -527,10 +530,16 @@
                                             connection,
                                             equals);
       if (! test_header (connection, argp, equals))
-       return MHD_NO;
+      {
+          free(argb);
+          return MHD_NO;
+      }
+      
       num_headers++;
       argp = amper;
     }
+    
+  free(argb);
 
   /* also check that the number of headers matches */
   for (pos = connection->headers_received; NULL != pos; pos = pos->next)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]