Skip to content

Commit

Permalink
Fix memory leak in corrupt JPEG decoding.
Browse files Browse the repository at this point in the history
BUG=10945
Review URL: http://codereview.chromium.org/113433

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16352 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
thestig@chromium.org committed May 19, 2009
1 parent 5ed4ba5 commit a191a50
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
4 changes: 2 additions & 2 deletions base/gfx/jpeg_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ bool JPEGCodec::Encode(const unsigned char* input, ColorFormat format,
int quality, std::vector<unsigned char>* output) {
jpeg_compress_struct cinfo;
CompressDestroyer destroyer;
destroyer.SetManagedObject(&cinfo);
output->clear();

// We set up the normal JPEG error routines, then override error_exit.
Expand All @@ -204,7 +205,6 @@ bool JPEGCodec::Encode(const unsigned char* input, ColorFormat format,

// The destroyer will destroy() cinfo on exit.
jpeg_create_compress(&cinfo);
destroyer.SetManagedObject(&cinfo);

cinfo.image_width = w;
cinfo.image_height = h;
Expand Down Expand Up @@ -395,6 +395,7 @@ bool JPEGCodec::Decode(const unsigned char* input, size_t input_size,
int* w, int* h) {
jpeg_decompress_struct cinfo;
DecompressDestroyer destroyer;
destroyer.SetManagedObject(&cinfo);
output->clear();

// We set up the normal JPEG error routines, then override error_exit.
Expand All @@ -414,7 +415,6 @@ bool JPEGCodec::Decode(const unsigned char* input, size_t input_size,
// The destroyer will destroy() cinfo on exit. We don't want to set the
// destroyer's object until cinfo is initialized.
jpeg_create_decompress(&cinfo);
destroyer.SetManagedObject(&cinfo);

// set up the source manager
jpeg_source_mgr srcmgr;
Expand Down
11 changes: 0 additions & 11 deletions tools/valgrind/suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -491,17 +491,6 @@
fun:_ZN17URLRequestHttpJob21NotifyHeadersCompleteEv
fun:_ZN17URLRequestHttpJob16OnStartCompletedEi
}
{
# See http://crbug.com/10945
bug_10945
Memcheck:Leak
fun:malloc
fun:jpeg_get_small
fun:jinit_memory_mgr
fun:jpeg_CreateDecompress
fun:_ZN9JPEGCodec6DecodeEPKhjNS_11ColorFormatEPSt6vectorIhSaIhEEPiS7_
fun:_ZN30JPEGCodec_DecodeCorrupted_Test8TestBodyEv
}
{
# See http://crbug.com/11116
bug_11116a
Expand Down

0 comments on commit a191a50

Please sign in to comment.