Fix memory leak in corrupt JPEG decoding.
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
This commit is contained in:
@@ -184,6 +184,7 @@ bool JPEGCodec::Encode(const unsigned char* input, ColorFormat format,
|
|||||||
int quality, std::vector<unsigned char>* output) {
|
int quality, std::vector<unsigned char>* output) {
|
||||||
jpeg_compress_struct cinfo;
|
jpeg_compress_struct cinfo;
|
||||||
CompressDestroyer destroyer;
|
CompressDestroyer destroyer;
|
||||||
|
destroyer.SetManagedObject(&cinfo);
|
||||||
output->clear();
|
output->clear();
|
||||||
|
|
||||||
// We set up the normal JPEG error routines, then override error_exit.
|
// We set up the normal JPEG error routines, then override error_exit.
|
||||||
@@ -204,7 +205,6 @@ bool JPEGCodec::Encode(const unsigned char* input, ColorFormat format,
|
|||||||
|
|
||||||
// The destroyer will destroy() cinfo on exit.
|
// The destroyer will destroy() cinfo on exit.
|
||||||
jpeg_create_compress(&cinfo);
|
jpeg_create_compress(&cinfo);
|
||||||
destroyer.SetManagedObject(&cinfo);
|
|
||||||
|
|
||||||
cinfo.image_width = w;
|
cinfo.image_width = w;
|
||||||
cinfo.image_height = h;
|
cinfo.image_height = h;
|
||||||
@@ -395,6 +395,7 @@ bool JPEGCodec::Decode(const unsigned char* input, size_t input_size,
|
|||||||
int* w, int* h) {
|
int* w, int* h) {
|
||||||
jpeg_decompress_struct cinfo;
|
jpeg_decompress_struct cinfo;
|
||||||
DecompressDestroyer destroyer;
|
DecompressDestroyer destroyer;
|
||||||
|
destroyer.SetManagedObject(&cinfo);
|
||||||
output->clear();
|
output->clear();
|
||||||
|
|
||||||
// We set up the normal JPEG error routines, then override error_exit.
|
// We set up the normal JPEG error routines, then override error_exit.
|
||||||
@@ -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
|
// The destroyer will destroy() cinfo on exit. We don't want to set the
|
||||||
// destroyer's object until cinfo is initialized.
|
// destroyer's object until cinfo is initialized.
|
||||||
jpeg_create_decompress(&cinfo);
|
jpeg_create_decompress(&cinfo);
|
||||||
destroyer.SetManagedObject(&cinfo);
|
|
||||||
|
|
||||||
// set up the source manager
|
// set up the source manager
|
||||||
jpeg_source_mgr srcmgr;
|
jpeg_source_mgr srcmgr;
|
||||||
|
@@ -491,17 +491,6 @@
|
|||||||
fun:_ZN17URLRequestHttpJob21NotifyHeadersCompleteEv
|
fun:_ZN17URLRequestHttpJob21NotifyHeadersCompleteEv
|
||||||
fun:_ZN17URLRequestHttpJob16OnStartCompletedEi
|
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
|
# See http://crbug.com/11116
|
||||||
bug_11116a
|
bug_11116a
|
||||||
|
Reference in New Issue
Block a user