diff options
author | noel@chromium.org <noel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-25 07:44:12 +0000 |
---|---|---|
committer | noel@chromium.org <noel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-25 07:44:12 +0000 |
commit | b03766fafc23b0777826747dabdfd17d41bd36bf (patch) | |
tree | 7a021198f348f273ec70996a03979c2f3597b2eb | |
parent | a97548744857e0542d9f96b392b8e1fb07c05980 (diff) | |
download | chromium_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
-rw-r--r-- | ui/gfx/codec/png_codec.cc | 4 | ||||
-rw-r--r-- | webkit/support/webkit_support_gfx.cc | 4 |
2 files changed, 6 insertions, 2 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()); diff --git a/webkit/support/webkit_support_gfx.cc b/webkit/support/webkit_support_gfx.cc index b9e1a3c..0331661 100644 --- a/webkit/support/webkit_support_gfx.cc +++ b/webkit/support/webkit_support_gfx.cc @@ -485,6 +485,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<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 @@ -505,7 +508,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()); |