]> granicus.if.org Git - clang/commitdiff
Fixed an offset calculation error.
authorZhongxing Xu <xuzhongxing@gmail.com>
Tue, 16 Sep 2008 07:58:21 +0000 (07:58 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Tue, 16 Sep 2008 07:58:21 +0000 (07:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56242 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Rewrite/RewriteRope.cpp

index 0a4dc8596844208a51d1d50b33e19eaef084f770..61cb02b9a591db88e54c465d2fea439ba6dcb98f 100644 (file)
@@ -792,7 +792,7 @@ RopePiece RewriteRope::MakeRopeString(const char *Start, const char *End) {
   if (AllocBuffer && --AllocBuffer->RefCount == 0)
     delete [] (char*)AllocBuffer;
   
-  unsigned AllocSize = sizeof(RopeRefCountString)-1+AllocChunkSize;
+  unsigned AllocSize = offsetof(RopeRefCountString, Data) + AllocChunkSize;
   AllocBuffer = reinterpret_cast<RopeRefCountString *>(new char[AllocSize]);
   AllocBuffer->RefCount = 0;
   memcpy(AllocBuffer->Data, Start, Len);