Fix a crash Anders' was seeing due to free'ing an invalid pointer

caused by my previous commit.

llvm-svn: 62613
This commit is contained in:
Chris Lattner 2009-01-20 21:06:38 +00:00
parent e5564628b4
commit 5742c1edc4
2 changed files with 12 additions and 12 deletions

View File

@ -521,6 +521,16 @@ struct DeclaratorChunk {
/// there are no arguments specified.
ParamInfo *ArgInfo;
/// freeArgs - reset the argument list to having zero arguments. This is
/// used in various places for error recovery.
void freeArgs() {
if (DeleteArgInfo) {
delete[] ArgInfo;
DeleteArgInfo = false;
}
NumArgs = 0;
}
void destroy() {
if (DeleteArgInfo)
delete[] ArgInfo;

View File

@ -1202,12 +1202,7 @@ bool Sema::CheckDestructorDeclarator(Declarator &D, QualType &R,
Diag(D.getIdentifierLoc(), diag::err_destructor_with_params);
// Delete the parameters.
DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
if (FTI.NumArgs) {
delete [] FTI.ArgInfo;
FTI.NumArgs = 0;
FTI.ArgInfo = 0;
}
D.getTypeObject(0).Fun.freeArgs();
}
// Make sure the destructor isn't variadic.
@ -1264,12 +1259,7 @@ bool Sema::CheckConversionDeclarator(Declarator &D, QualType &R,
Diag(D.getIdentifierLoc(), diag::err_conv_function_with_params);
// Delete the parameters.
DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
if (FTI.NumArgs) {
delete [] FTI.ArgInfo;
FTI.NumArgs = 0;
FTI.ArgInfo = 0;
}
D.getTypeObject(0).Fun.freeArgs();
}
// Make sure the conversion function isn't variadic.