diff options
author | Caolán McNamara <caolanm@redhat.com> | 2010-11-08 14:36:19 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2010-11-08 14:36:19 +0000 |
commit | e5d9b97978ebf3b45c86995859cebe6f6286cb77 (patch) | |
tree | 6397c0687782fd89229fe31586f946b35a5dc0e2 /hwpfilter | |
parent | cppcheck reported memory leak (diff) | |
download | core-e5d9b97978ebf3b45c86995859cebe6f6286cb77.tar.gz core-e5d9b97978ebf3b45c86995859cebe6f6286cb77.zip |
cppcheck release memory on some more early return paths
Diffstat (limited to 'hwpfilter')
-rw-r--r-- | hwpfilter/source/htags.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/hwpfilter/source/htags.cpp b/hwpfilter/source/htags.cpp index b654f85ca32c..6f1ade734457 100644 --- a/hwpfilter/source/htags.cpp +++ b/hwpfilter/source/htags.cpp @@ -138,31 +138,33 @@ bool OlePicture::Read(HWPFile & hwpf) if (signature != FILESTG_SIGNATURE_NORMAL) return false; #ifdef WIN32 - char *data; - data = new char[size]; - if( data == 0 || hwpf.ReadBlock(data,size) == 0 ) - return false; - FILE *fp; - char tname[200]; - wchar_t wtname[200]; - tmpnam(tname); - if (0 == (fp = fopen(tname, "wb"))) - { + char *data = new char[size]; + if( data == 0 || hwpf.ReadBlock(data,size) == 0 ) + { delete [] data; return false; - } - fwrite(data, size, 1, fp); - fclose(fp); - MultiByteToWideChar(CP_ACP, 0, tname, -1, wtname, 200); - if( StgOpenStorage(wtname, NULL, - STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED, - NULL, 0, &pis) != S_OK ) { - pis = 0; - unlink(tname); - return false; - } - unlink(tname); - delete [] data; + } + FILE *fp; + char tname[200]; + wchar_t wtname[200]; + tmpnam(tname); + if (0 == (fp = fopen(tname, "wb"))) + { + delete [] data; + return false; + } + fwrite(data, size, 1, fp); + delete [] data; + fclose(fp); + MultiByteToWideChar(CP_ACP, 0, tname, -1, wtname, 200); + if( StgOpenStorage(wtname, NULL, + STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED, + NULL, 0, &pis) != S_OK ) { + pis = 0; + unlink(tname); + return false; + } + unlink(tname); #else if (pis == 0 || hwpf.ReadBlock(pis, size) == 0) return false; |