diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-06-04 11:37:05 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-06-04 11:37:05 +0000 |
commit | e5e5034111debe060863901dbfe3728cc30d6441 (patch) | |
tree | 6a8b7238801f15a0217f60313187b1a16e3297a2 /src/microhttpd/digestauth.c | |
parent | 31d84d44a39ef70cfa31982d0b3a96052d28c272 (diff) | |
download | libmicrohttpd-e5e5034111debe060863901dbfe3728cc30d6441.tar.gz libmicrohttpd-e5e5034111debe060863901dbfe3728cc30d6441.zip |
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
Diffstat (limited to 'src/microhttpd/digestauth.c')
-rw-r--r-- | src/microhttpd/digestauth.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c index 4cc7f61b..e69f58aa 100644 --- a/src/microhttpd/digestauth.c +++ b/src/microhttpd/digestauth.c | |||
@@ -508,7 +508,10 @@ check_argument_match (struct MHD_Connection *connection, | |||
508 | connection, | 508 | connection, |
509 | argp); | 509 | argp); |
510 | if (MHD_YES != test_header (connection, argp, NULL)) | 510 | if (MHD_YES != test_header (connection, argp, NULL)) |
511 | return MHD_NO; | 511 | { |
512 | free(argb); | ||
513 | return MHD_NO; | ||
514 | } | ||
512 | num_headers++; | 515 | num_headers++; |
513 | break; | 516 | break; |
514 | } | 517 | } |
@@ -527,10 +530,16 @@ check_argument_match (struct MHD_Connection *connection, | |||
527 | connection, | 530 | connection, |
528 | equals); | 531 | equals); |
529 | if (! test_header (connection, argp, equals)) | 532 | if (! test_header (connection, argp, equals)) |
530 | return MHD_NO; | 533 | { |
534 | free(argb); | ||
535 | return MHD_NO; | ||
536 | } | ||
537 | |||
531 | num_headers++; | 538 | num_headers++; |
532 | argp = amper; | 539 | argp = amper; |
533 | } | 540 | } |
541 | |||
542 | free(argb); | ||
534 | 543 | ||
535 | /* also check that the number of headers matches */ | 544 | /* also check that the number of headers matches */ |
536 | for (pos = connection->headers_received; NULL != pos; pos = pos->next) | 545 | for (pos = connection->headers_received; NULL != pos; pos = pos->next) |