Hi!
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
--- bla/libmicrohttpd/src/microhttpd/digestauth.c 2015-05-29 12:20:53.027686000 +0200
+++ digestauth.c 2015-06-04 13:11:08.123697504 +0200
@@ -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)