PATCH : free(NULL) in cpphash.c
Philippe De Muyter
phdm@macqel.be
Tue Apr 4 21:49:00 GMT 2000
In cpphash.c/_cpp_free_definition, one frees d->argnames iff d->nargs >= 0.
But in collect_expansion, nargs is copied from argc which itself is a copy
of arglist->argc while argnames is copied from arglist->namebuf. And in
collect_formal_parameters, argc can set to 0 while namebuf is set to NULL.
In short, argnames can be NULL even when nargs >= 0.
Suggested fix :
Philippe De Muyter <phdm@macqel.be>
* cpphash.c (_cpp_free_definition): Test `argnames', not `nargs >= 0',
before calling `free (argnames)'.
Index: gcc/cpphash.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpphash.c,v
retrieving revision 1.61
diff -u -p -r1.61 cpphash.c
--- cpphash.c 2000/04/01 22:55:24 1.61
+++ cpphash.c 2000/04/05 04:35:20
@@ -256,7 +256,7 @@ _cpp_free_definition (d)
nextap = ap->next;
free (ap);
}
- if (d->nargs >= 0)
+ if (d->argnames)
free (d->argnames);
free (d);
}
More information about the Gcc-patches
mailing list