I am not sure scoped_array helps cause of comment in JPEGCodec::Encode
().

  if (setjmp(errmgr.setjmp_buffer)) {
    // If we get here, the JPEG code has signaled an error.
    // MSDN notes: "if you intend your code to be portable, do not
rely on
    // correct destruction of frame-based objects when executing a
nonlocal
    // goto using a call to longjmp."  So we delete the
CompressDestroyer's
    // object manually instead.
    destroyer.DestroyManagedObject();
    return false;
  }

Probably it will be better use IJG memory manager. For example code in
module JPEGImageDecoder.cpp,
member function WebCore::JPEGImageReader::decode() :

/*
* Make a one-row-high sample array that will go away
* when done with image. Always make it big enough to
* hold an RGB row.  Since this uses the IJG memory
* manager, it must be allocated before the call to
* jpeg_start_compress().
*/
int row_stride = m_info.output_width * 4; // RGBA buffer


m_samples = (*m_info.mem->alloc_sarray)((j_common_ptr) &m_info,
                                        JPOOL_IMAGE,
                                        row_stride, 1);

I think comment "it must be allocated before the call to
jpeg_start_compress()" is invalid (I am not sure).

On 2 июл, 21:01, Lei Zhang <[email protected]> wrote:
> It probably needs to be converted into a scoped_array like in
> JPEGCodec::Decode. Can you file a bug for this onhttp://crbug.com/?
>
>
>
> On Thu, Jul 2, 2009 at 5:59 AM, runtime<[email protected]> wrote:
>
> > Hi
> > There is memory leak in the module jpeg_codec.cc, member function
>
> > bool JPEGCodec::Encode(const unsigned char* input, ColorFormat format,
> >                       int w, int h, int row_byte_width,
> >                       int quality, std::vector<unsigned char>*
> > output);
>
> > code
>
> >    // output row after converting
> >    unsigned char* row = new unsigned char[w * 3];
>
> >    while (cinfo.next_scanline < cinfo.image_height) {
> >      converter(&input[cinfo.next_scanline * row_byte_width], w, row);
> >      jpeg_write_scanlines(&cinfo, &row, 1);
> >    }
> >    delete[] row;
>
> > The allocated in row pointer memory will not be released if error
> > happens in libjpeg.- Скрыть цитируемый текст -
>
> - Показать цитируемый текст -
--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: [email protected] 
View archives, change email options, or unsubscribe: 
    http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to