summaryrefslogtreecommitdiff
path: root/lib/Archive
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2009-06-11 08:09:49 +0000
committerDuncan Sands <baldrick@free.fr>2009-06-11 08:09:49 +0000
commit861d20aab446cce039e5e142091735d99fb426ef (patch)
tree2979b652536256200d3e68ee90310ffcddbc8e3c /lib/Archive
parentfa3f80a2b7019de1a24be7e43132dfc1576db1b1 (diff)
Avoid leaking memory in an error path. Noticed
by cppcheck. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73187 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Archive')
-rw-r--r--lib/Archive/ArchiveWriter.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Archive/ArchiveWriter.cpp b/lib/Archive/ArchiveWriter.cpp
index 336a2bdc658..cebb0877457 100644
--- a/lib/Archive/ArchiveWriter.cpp
+++ b/lib/Archive/ArchiveWriter.cpp
@@ -167,10 +167,11 @@ Archive::addFileBefore(const sys::Path& filePath, iterator where,
mbr->data = 0;
mbr->path = filePath;
const sys::FileStatus *FSInfo = mbr->path.getFileStatus(false, ErrMsg);
- if (FSInfo)
- mbr->info = *FSInfo;
- else
+ if (!FSInfo) {
+ delete mbr;
return true;
+ }
+ mbr->info = *FSInfo;
unsigned flags = 0;
bool hasSlash = filePath.toString().find('/') != std::string::npos;