dyngen: Don't leak func_name if realloc fails

This commit is contained in:
Alexander von Gluck IV
2012-06-30 22:48:46 -05:00
committed by Alexei Svitkine
parent 612761981f
commit 668b8f14ba

View File

@@ -2942,9 +2942,11 @@ int gen_file(FILE *outfile, int out_type)
int func_name_length = p - demangled_name;
if (nd > nf) {
nf = nd;
if ((func_name = realloc(func_name, nf)) == NULL)
if ((func_name = realloc(func_name, nf)) == NULL) {
free(func_name);
return -1;
}
}
strncpy(func_name, demangled_name, func_name_length);
func_name[func_name_length] = '\0';
/* emit code generator */