summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authornoel@chromium.org <noel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-25 07:44:12 +0000
committernoel@chromium.org <noel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-25 07:44:12 +0000
commitb03766fafc23b0777826747dabdfd17d41bd36bf (patch)
tree7a021198f348f273ec70996a03979c2f3597b2eb /ui/gfx
parenta97548744857e0542d9f96b392b8e1fb07c05980 (diff)
downloadchromium_src-b03766fafc23b0777826747dabdfd17d41bd36bf.zip
chromium_src-b03766fafc23b0777826747dabdfd17d41bd36bf.tar.gz
chromium_src-b03766fafc23b0777826747dabdfd17d41bd36bf.tar.bz2
Comment memory leak in the PNG encoder on encoding error.
Commment class leaks if setjmp() is called on encoding error. Fix by creating the class instance before the setjmp() point. The class is then on the stack no matter which way the routine exits, setjmp() or otherwise, and thus its class destructor is always called. BUG=171897 Review URL: https://chromiumcodereview.appspot.com/12035071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178774 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/codec/png_codec.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/ui/gfx/codec/png_codec.cc b/ui/gfx/codec/png_codec.cc
index 79d1850b..1b8b5c7 100644
--- a/ui/gfx/codec/png_codec.cc
+++ b/ui/gfx/codec/png_codec.cc
@@ -602,6 +602,9 @@ bool DoLibpngWrite(png_struct* png_ptr, png_info* info_ptr,
int png_output_color_type, int output_color_components,
FormatConverter converter,
const std::vector<PNGCodec::Comment>& comments) {
+#ifdef PNG_TEXT_SUPPORTED
+ CommentWriter comment_writer(comments);
+#endif
unsigned char* row_buffer = NULL;
// Make sure to not declare any locals here -- locals in the presence
@@ -623,7 +626,6 @@ bool DoLibpngWrite(png_struct* png_ptr, png_info* info_ptr,
PNG_FILTER_TYPE_DEFAULT);
#ifdef PNG_TEXT_SUPPORTED
- CommentWriter comment_writer(comments);
if (comment_writer.HasComments()) {
png_set_text(png_ptr, info_ptr, comment_writer.get_png_text(),
comment_writer.size());