Эх сурвалжийг харах

Fixed an offset calculation error.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56242 91177308-0d34-0410-b5e6-96231b3b80d8
Zhongxing Xu 17 жил өмнө
parent
commit
3f61c18dd7

+ 1 - 1
lib/Rewrite/RewriteRope.cpp

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