when the bitcode reader is referencing a paramattr, make sure to bump its refcount.
authorChris Lattner <sabre@nondot.org>
Wed, 12 Mar 2008 02:25:52 +0000 (02:25 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 12 Mar 2008 02:25:52 +0000 (02:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48276 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bitcode/Reader/BitcodeReader.cpp

index a58ead5f14c4e35bd396b8b617131e2b4df665e4..c86ee3048a9b65cd4df0a4ce4768e77bff6c1301 100644 (file)
@@ -31,6 +31,11 @@ void BitcodeReader::FreeState() {
   Buffer = 0;
   std::vector<PATypeHolder>().swap(TypeList);
   ValueList.clear();
+  
+  // Drop references to ParamAttrs.
+  for (unsigned i = 0, e = ParamAttrs.size(); i != e; ++i)
+    ParamAttrs[i]->dropRef();
+  
   std::vector<const ParamAttrsList*>().swap(ParamAttrs);
   std::vector<BasicBlock*>().swap(FunctionBBs);
   std::vector<Function*>().swap(FunctionsWithBodies);
@@ -237,7 +242,13 @@ bool BitcodeReader::ParseParamAttrBlock() {
         if (Record[i+1] != ParamAttr::None)
           Attrs.push_back(ParamAttrsWithIndex::get(Record[i], Record[i+1]));
       }
-      ParamAttrs.push_back(Attrs.empty() ? NULL : ParamAttrsList::get(Attrs));
+      if (Attrs.empty()) {
+        ParamAttrs.push_back(0);
+      } else {
+        ParamAttrs.push_back(ParamAttrsList::get(Attrs));
+        ParamAttrs.back()->addRef();
+      }
+
       Attrs.clear();
       break;
     }