[cfe-commits] r68634 - /cfe/trunk/lib/AST/ASTContext.cpp

Daniel Dunbar daniel at zuster.org
Wed Apr 8 13:48:55 PDT 2009


Ok, I didn't look at the code very closely just wanted to solve a memory
corruption problem. Can you make the change and perhaps add an assert that i
isn't out of bounds in the layout code?
 - Daniel

On Wed, Apr 8, 2009 at 1:41 PM, Fariborz Jahanian <fjahanian at apple.com>wrote:

>
> On Apr 8, 2009, at 1:18 PM, Daniel Dunbar wrote:
>
>  Author: ddunbar
>> Date: Wed Apr  8 15:18:15 2009
>> New Revision: 68634
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=68634&view=rev
>> Log:
>> Fix buffer overrun when laying out synthesized ivars.
>>
>> 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=68634&r1=68633&r2=68634&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> ======================================================================
>> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTContext.cpp Wed Apr  8 15:18:15 2009
>> @@ -679,7 +679,8 @@
>>  // Allocate and assign into ASTRecordLayouts here.  The "Entry" reference
>> can
>>  // be invalidated (dangle) if the ASTRecordLayouts hashtable is inserted
>> into.
>>  ASTRecordLayout *NewEntry = NULL;
>> -  unsigned FieldCount = D->ivar_size();
>> +  unsigned FieldCount =
>> +    D->ivar_size() + std::distance(D->prop_begin(), D->prop_end());
>>
>
> This is the upper bound and is  harmless. An accurate count
> is preferred though to assert more strictly in:
>
> void SetFieldOffset(unsigned FieldNo, uint64_t Offset) {
>    assert (FieldNo < FieldCount && "Invalid Field No");
>    FieldOffsets[FieldNo] = Offset;
>  }
>
>
> - Fariborz
>
>
>
>
>>  if (ObjCInterfaceDecl *SD = D->getSuperClass()) {
>>    FieldCount++;
>>    const ASTRecordLayout &SL = getASTObjCInterfaceLayout(SD);
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20090408/55334cc8/attachment.html>


More information about the cfe-commits mailing list