[Libreoffice-commits] .: 2 commits - hwpfilter/source
Caolán McNamara
caolan at kemper.freedesktop.org
Mon Nov 8 06:36:31 PST 2010
hwpfilter/source/htags.cpp | 47 ++++++++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 21 deletions(-)
New commits:
commit 2f531088fe2e6e36af5d2c7930e35dca760b9b1a
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Nov 8 14:36:19 2010 +0000
cppcheck release memory on some more early return paths
diff --git a/hwpfilter/source/htags.cpp b/hwpfilter/source/htags.cpp
index 8c5c84c..5e05d75 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;
commit e954f0159399dce5b69ec57b0fb50b6ddbf4dc87
Author: julien <serval2412 at yahoo.fr>
Date: Mon Nov 8 14:20:07 2010 +0000
cppcheck reported memory leak
diff --git a/hwpfilter/source/htags.cpp b/hwpfilter/source/htags.cpp
index 8235bf0..8c5c84c 100644
--- a/hwpfilter/source/htags.cpp
+++ b/hwpfilter/source/htags.cpp
@@ -147,7 +147,10 @@ bool OlePicture::Read(HWPFile & hwpf)
wchar_t wtname[200];
tmpnam(tname);
if (0 == (fp = fopen(tname, "wb")))
+ {
+ delete [] data;
return false;
+ }
fwrite(data, size, 1, fp);
fclose(fp);
MultiByteToWideChar(CP_ACP, 0, tname, -1, wtname, 200);
More information about the Libreoffice-commits
mailing list