src/file_sig.c: fix memory leak in error paths

This commit is contained in:
Christophe Grenier 2013-11-01 12:18:30 +01:00
parent 971d0b8f4a
commit 2237a01ed0

View file

@ -242,6 +242,7 @@ static char *parse_signature_file(file_stat_t *file_stat, char *pos)
if(*pos=='\0') if(*pos=='\0')
{ {
free(extension); free(extension);
free(tmp);
return pos; return pos;
} }
else if(*pos=='\\') else if(*pos=='\\')
@ -250,6 +251,7 @@ static char *parse_signature_file(file_stat_t *file_stat, char *pos)
if(*pos=='\0') if(*pos=='\0')
{ {
free(extension); free(extension);
free(tmp);
return pos; return pos;
} }
else if(*pos=='b') else if(*pos=='b')
@ -274,6 +276,7 @@ static char *parse_signature_file(file_stat_t *file_stat, char *pos)
if(*pos!='\'') if(*pos!='\'')
{ {
free(extension); free(extension);
free(tmp);
return pos; return pos;
} }
pos++; pos++;
@ -301,6 +304,7 @@ static char *parse_signature_file(file_stat_t *file_stat, char *pos)
if(*pos=='\0') if(*pos=='\0')
{ {
free(extension); free(extension);
free(tmp);
return pos; return pos;
} }
else if(*pos=='b') else if(*pos=='b')
@ -322,6 +326,7 @@ static char *parse_signature_file(file_stat_t *file_stat, char *pos)
if(*pos!='"') if(*pos!='"')
{ {
free(extension); free(extension);
free(tmp);
return pos; return pos;
} }
pos++; pos++;
@ -354,6 +359,7 @@ static char *parse_signature_file(file_stat_t *file_stat, char *pos)
else else
{ {
free(extension); free(extension);
free(tmp);
return pos; return pos;
} }
} }
@ -398,6 +404,7 @@ static void register_header_check_sig(file_stat_t *file_stat)
if(fread(buffer,1,buffer_size,handle)!=buffer_size) if(fread(buffer,1,buffer_size,handle)!=buffer_size)
{ {
fclose(handle); fclose(handle);
free(buffer);
return; return;
} }
fclose(handle); fclose(handle);