Make sure the Archive gets deleted if there's an error.

llvm-svn: 18869
This commit is contained in:
Reid Spencer 2004-12-13 03:22:31 +00:00
parent 22b7eac855
commit ac9fe82875
1 changed files with 4 additions and 4 deletions

View File

@ -282,9 +282,9 @@ Archive::loadArchive() {
Archive* Archive*
Archive::OpenAndLoad(const sys::Path& file, std::string* ErrorMessage) { Archive::OpenAndLoad(const sys::Path& file, std::string* ErrorMessage) {
try { try {
Archive* result = new Archive(file, true); std::auto_ptr<Archive> result ( new Archive(file, true));
result->loadArchive(); result->loadArchive();
return result; return result.release();
} catch (const std::string& msg) { } catch (const std::string& msg) {
if (ErrorMessage) { if (ErrorMessage) {
*ErrorMessage = msg; *ErrorMessage = msg;
@ -377,9 +377,9 @@ Archive::loadSymbolTable() {
Archive* Archive*
Archive::OpenAndLoadSymbols(const sys::Path& file, std::string* ErrorMessage) { Archive::OpenAndLoadSymbols(const sys::Path& file, std::string* ErrorMessage) {
try { try {
Archive* result = new Archive(file, true); std::auto_ptr<Archive> result ( new Archive(file, true) );
result->loadSymbolTable(); result->loadSymbolTable();
return result; return result.release();
} catch (const std::string& msg) { } catch (const std::string& msg) {
if (ErrorMessage) { if (ErrorMessage) {
*ErrorMessage = msg; *ErrorMessage = msg;