From c5f3e5371c2458669650804eac76d790d88ab271 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 15 Nov 2007 00:05:03 +0000 Subject: [PATCH] Fixed serious bug in BatchReadOwnedPtrs where in a chain of calls to deserialize objects if BatchReadOwnedPtrs was called more than once in the same call chain then the second call would overwrite the SerializedPtrIDs being used by the first call. Solved this problem by making the vector that holds the pointer IDs local to a function call. Now BatchReadOwnedPtrs is reentrant. llvm-svn: 44152 --- llvm/include/llvm/Bitcode/Deserialize.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/Bitcode/Deserialize.h b/llvm/include/llvm/Bitcode/Deserialize.h index 68d94b773d17..d0ededef9fc5 100644 --- a/llvm/include/llvm/Bitcode/Deserialize.h +++ b/llvm/include/llvm/Bitcode/Deserialize.h @@ -126,7 +126,6 @@ private: unsigned AbbrevNo; unsigned RecordCode; Location StreamStart; - std::vector BatchIDVec; //===----------------------------------------------------------===// // Public Interface. @@ -213,7 +212,7 @@ public: template void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, bool AutoRegister=true) { - BatchIDVec.clear(); + llvm::SmallVector BatchIDVec; for (unsigned i = 0; i < NumPtrs; ++i) BatchIDVec.push_back(ReadPtrID()); @@ -234,8 +233,8 @@ public: void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2, bool A1=true, bool A2=true) { - BatchIDVec.clear(); - + llvm::SmallVector BatchIDVec; + for (unsigned i = 0; i < NumT1Ptrs; ++i) BatchIDVec.push_back(ReadPtrID()); @@ -261,7 +260,7 @@ public: T2*& P2, T3*& P3, bool A1=true, bool A2=true, bool A3=true) { - BatchIDVec.clear(); + llvm::SmallVector BatchIDVec; for (unsigned i = 0; i < NumT1Ptrs; ++i) BatchIDVec.push_back(ReadPtrID());