[llvm-commits] [llvm] r73187 - /llvm/trunk/lib/Archive/ArchiveWriter.cpp
Duncan Sands
baldrick at free.fr
Thu Jun 11 01:09:54 PDT 2009
Author: baldrick
Date: Thu Jun 11 03:09:49 2009
New Revision: 73187
URL: http://llvm.org/viewvc/llvm-project?rev=73187&view=rev
Log:
Avoid leaking memory in an error path. Noticed
by cppcheck.
Modified:
llvm/trunk/lib/Archive/ArchiveWriter.cpp
Modified: llvm/trunk/lib/Archive/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Archive/ArchiveWriter.cpp?rev=73187&r1=73186&r2=73187&view=diff
==============================================================================
--- llvm/trunk/lib/Archive/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Archive/ArchiveWriter.cpp Thu Jun 11 03:09:49 2009
@@ -167,10 +167,11 @@
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;
More information about the llvm-commits
mailing list