[Libevent-users] fix for memory leak in evhttp_handle_chunked_read

Elliot F elliotf-libevent at gratuitous.net
Thu Jul 26 14:57:42 EDT 2007


A fix for a small memory leak in http.c's evhttp_handle_chunked_read.

Thanks,

Elliot

diff -Naur libevent-1.3b_orig/http.c libevent-1.3b_modified/http.c
--- libevent-1.3b_orig/http.c   2007-03-03 20:05:04.000000000 -0800
+++ libevent-1.3b_modified/http.c       2007-07-26 11:46:33.000000000 -0700
@@ -640,8 +640,10 @@
                        if (p == NULL)
                                break;
                        /* the last chunk is on a new line? */
-                       if (strlen(p) == 0)
+                       if (strlen(p) == 0) {
+                               free(p);
                                continue;
+                       }
                        req->ntoread = strtol(p, &endp, 16);
                        error = *p == '\0' || (*endp != '\0' && *endp != ' ');
                        free(p);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: memleak_fix-evhttp_handle_chunked_read.patch
Type: text/x-patch
Size: 497 bytes
Desc: not available
Url : http://monkeymail.org/archives/libevent-users/attachments/20070726/dbbfd276/memleak_fix-evhttp_handle_chunked_read.bin


More information about the Libevent-users mailing list