Fixed possible memory leak in lowercase function.

If user passed NULL pointer to lowercase() function, duplicated
string "new" wasn't freed before return.

Signed-off-by: Dmitry V. Krivenok <krivenok@orangesystem.ru>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
This commit is contained in:
Dmitry V. Krivenok
2009-09-10 16:08:41 +04:00
committed by Andreas Schneider
parent 2a10019f82
commit 18bce13617

View File

@@ -1019,11 +1019,12 @@ static int alldigits(const char *s) {
*/
static char *lowercase(const char* str) {
char *p = 0;
char *new = strdup(str);
char *new = NULL;
if((str == NULL) || (new == NULL)) {
return NULL;
}
if(str == NULL) return NULL;
new = strdup(str);
if(new == NULL) return NULL;
for (p = new; *p; p++) {
*p = tolower(*p);