소스 검색

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 년 전
부모
커밋
3f61c18dd7
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      lib/Rewrite/RewriteRope.cpp

+ 1 - 1
lib/Rewrite/RewriteRope.cpp

@@ -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);