diff options
author | scuri <scuri> | 2009-11-23 17:11:42 +0000 |
---|---|---|
committer | scuri <scuri> | 2009-11-23 17:11:42 +0000 |
commit | 50c8a0c91a1dd2fad6f6c7f86283f0dc9760a29e (patch) | |
tree | a60137d4542c0e54ff22cfb5e5245b506a5decae | |
parent | 9cc6fd6da62bc239bf22ced6ae24c0ffdd994b40 (diff) |
Fixed: memory leak in imFileOpen.
-rw-r--r-- | html/en/history.html | 4 | ||||
-rw-r--r-- | include/im.h | 2 | ||||
-rw-r--r-- | src/im_file.cpp | 3 | ||||
-rw-r--r-- | src/im_format.cpp | 23 |
4 files changed, 24 insertions, 8 deletions
diff --git a/html/en/history.html b/html/en/history.html index fdf2b46..76df670 100644 --- a/html/en/history.html +++ b/html/en/history.html @@ -12,11 +12,13 @@ <h2>History of Changes</h2> <h3 dir="ltr"> - CVS (20/11/2009</h3> + CVS (23/11/2009</h3> <ul dir="ltr"> <li dir="ltr"><span style="color: #008000"><span style="color: #ff0000">Fixed:</span><span style="color: #000000"> invalid memory access in <strong> imAnalyzeFindRegions</strong> when more than 16k regions where found.</span></span></li> + <li dir="ltr"><span style="color: #008000"><span style="color: #ff0000">Fixed:</span><span + style="color: #000000"> memory leak in <strong>imFileOpen</strong>.</span></span></li> </ul> <h3 dir="ltr"> <a href="http://sourceforge.net/projects/imtoolkit/files/3.5/">Version 3.5</a> (02/Oct/2009)</h3> diff --git a/include/im.h b/include/im.h index a324199..307e0a3 100644 --- a/include/im.h +++ b/include/im.h @@ -235,7 +235,7 @@ int imFileWriteImageData(imFile* ifile, void* data); * \ingroup format */ void imFormatRegisterInternal(void); -/** Remove all registered formats. +/** Remove all registered formats. Call this if you are checking memory leaks. * \ingroup format */ void imFormatRemoveAll(void); diff --git a/src/im_file.cpp b/src/im_file.cpp index 3bfa779..9a4519a 100644 --- a/src/im_file.cpp +++ b/src/im_file.cpp @@ -2,7 +2,7 @@ * \brief File Access * * See Copyright Notice in im_lib.h - * $Id: im_file.cpp,v 1.5 2009/08/23 23:57:51 scuri Exp $ + * $Id: im_file.cpp,v 1.6 2009/11/23 17:13:05 scuri Exp $ */ #include <stdlib.h> @@ -125,6 +125,7 @@ void imFileClose(imFile* ifile) if (ifile->line_buffer) free(ifile->line_buffer); delete attrib_table; + delete ifileformat; } void* imFileHandle(imFile* ifile, int index) diff --git a/src/im_format.cpp b/src/im_format.cpp index d389743..ad04a3b 100644 --- a/src/im_format.cpp +++ b/src/im_format.cpp @@ -2,7 +2,7 @@ * \brief File Format Access * * See Copyright Notice in im_lib.h - * $Id: im_format.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ + * $Id: im_format.cpp,v 1.3 2009/11/23 17:13:05 scuri Exp $ */ @@ -194,7 +194,7 @@ imFileFormatBase* imFileFormatBaseOpen(const char* file_name, int *error) imFileFormatBase* ifileformat = iformat->Create(); *error = ifileformat->Open(file_name); if (*error != IM_ERR_NONE && *error != IM_ERR_FORMAT) // Error situation that must abort - { // Only IM_ERR_FORMAT is a valid error here + { // Only IM_ERR_FORMAT is considered here free(extension); delete [] ext_mark; delete ifileformat; @@ -206,6 +206,11 @@ imFileFormatBase* imFileFormatBaseOpen(const char* file_name, int *error) delete [] ext_mark; return ifileformat; } + else + { + /* Other errors, release the format and test another one */ + delete ifileformat; + } } } @@ -233,6 +238,11 @@ imFileFormatBase* imFileFormatBaseOpen(const char* file_name, int *error) delete [] ext_mark; return ifileformat; } + else + { + /* Other errors, release the format and test another one */ + delete ifileformat; + } } } @@ -269,9 +279,12 @@ imFileFormatBase* imFileFormatBaseOpenAs(const char* file_name, const char* form } else if (*error == IM_ERR_NONE) // Sucessfully oppened the file return ifileformat; - - *error = IM_ERR_FORMAT; - return NULL; + else + { + *error = IM_ERR_FORMAT; + delete ifileformat; + return NULL; + } } imFileFormatBase* imFileFormatBaseNew(const char* file_name, const char* format, int *error) |