Hi Fariborz, It's great that you did this, but please don't use alloca. It's not portable, and is strictly prohibited in the LLVM codebase. Please use a SmallVector or something else.
On Oct 23, 2009, at 5:16 PM, Fariborz Jahanian wrote: > Author: fjahanian > Date: Fri Oct 23 19:16:42 2009 > New Revision: 84981 > > URL: http://llvm.org/viewvc/llvm-project?rev=84981&view=rev > Log: > Make the local buffer overflow safe. > > > Modified: > cfe/trunk/lib/AST/ASTContext.cpp > > Modified: cfe/trunk/lib/AST/ASTContext.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=84981&r1=84980&r2=84981&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- cfe/trunk/lib/AST/ASTContext.cpp (original) > +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Oct 23 19:16:42 2009 > @@ -2854,11 +2854,10 @@ > bool HasCopyAndDispose = BlockRequiresCopying(Ty); > > // FIXME: Move up > - static int UniqueBlockByRefTypeID = 0; > - // FIXME. This is error prone. Luckinly stack-canary stuff caught > it. > - char Name[128]; > + static unsigned int UniqueBlockByRefTypeID = 0; > + char * Name = > + (char*)alloca(strlen("__Block_byref_") + 10 + 1 + strlen > (DeclName) + 1); > sprintf(Name, "__Block_byref_%d_%s", ++UniqueBlockByRefTypeID, > DeclName); > - assert((strlen(Name) < sizeof(Name)) && "BuildByRefType - buffer > overflow"); > RecordDecl *T; > T = RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, > SourceLocation(), > &Idents.get(Name)); > @@ -2905,11 +2904,10 @@ > bool BlockHasCopyDispose, > llvm::SmallVector<const Expr *, 8> &BlockDeclRefDecls) { > // FIXME: Move up > - static int UniqueBlockParmTypeID = 0; > - // FIXME. This is error prone. Luckinly stack-canary stuff caught > it. > - char Name[128]; > + static unsigned int UniqueBlockParmTypeID = 0; > + char * Name = > + (char*)alloca(strlen("__block_literal_") + 10 + 1); > sprintf(Name, "__block_literal_%u", ++UniqueBlockParmTypeID); > - assert((strlen(Name) < sizeof(Name)) && "getBlockParmType - > buffer overflow"); > RecordDecl *T; > T = RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, > SourceLocation(), > &Idents.get(Name)); > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
