[Libcgi-general] Memory Leak - patch included
Brought to you by:
rafaelsteil
From: Erich S. <er...@de...> - 2003-09-25 13:36:18
|
Hello, libcgi still has some memory leak in cgi_process_form. cgi_unescape_special_chars() will alloc a new string, but the result is not freed() in cgi.c:116 (the pointer is not even kept) Here is a patch that should fix this bug: --- libcgi-0.8.2.orig/src/cgi.c +++ libcgi-0.8.2/src/cgi.c @@ -109,11 +109,8 @@ i++; } - data->value = (char *)malloc(position+1); - if (data->value == NULL) - libcgi_error(E_MEMORY, "%s, line %s", __FILE__, __LINE__); - strncpy(data->value, cgi_unescape_special_chars(query), position); position);*/ + data->value = cgi_unescape_special_chars(query); data->value[position] = '\0'; list_add(data, start, last); Greetings, Erich Schubert -- erich@(vitavonni.de|debian.org) -- GPG Key ID: 4B3A135C (o_ Which is worse: ignorance or apathy? Who knows? Who cares? //\ Wer keine Zeit mehr mit echten Freunden verbringt, der wird bald V_/_ sein Gleichgewicht verlieren. --- Michael Levine |