diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index db87f76d81d..116143e1685 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -643,7 +643,7 @@ static void writeSymbolTable( unsigned StartOffset = 0; unsigned MemberNum = 0; std::vector SymNames; - std::vector > DeleteIt; + std::vector DeleteIt; for (ArrayRef::iterator I = Members.begin(), E = Members.end(); I != E; ++I, ++MemberNum) { @@ -665,7 +665,7 @@ static void writeSymbolTable( } if (!Obj) continue; - DeleteIt.push_back(OwningPtr(Obj)); + DeleteIt.push_back(Obj); if (!StartOffset) { printMemberHeader(Out, "", sys::TimeValue::now(), 0, 0, 0, 0); StartOffset = Out.tell(); @@ -698,6 +698,13 @@ static void writeSymbolTable( Out << '\0'; } + for (std::vector::iterator I = DeleteIt.begin(), + E = DeleteIt.end(); + I != E; ++I) { + object::ObjectFile *O = *I; + delete O; + } + if (StartOffset == 0) return;