After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 163348 - [pngenc] Leaks and other nasty stuff
[pngenc] Leaks and other nasty stuff
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins
git master
Other Linux
: Normal major
: 0.8.8
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-01-08 17:12 UTC by Gergely Nagy
Modified: 2005-01-09 01:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch fixing the mentioned problems. (2.85 KB, patch)
2005-01-08 17:14 UTC, Gergely Nagy
none Details | Review

Description Gergely Nagy 2005-01-08 17:12:06 UTC
gst_pngenc_chain() does not unref the buffer it got on most error paths, nor
does it free the libpng structures. There are a few places where it can simply
corrupt memory on error. Observe this code, from gst_pngenc_chain():

  pngenc->png_info_ptr = png_create_info_struct (pngenc->png_struct_ptr);
  if (!pngenc->png_info_ptr) {
    png_destroy_read_struct (&(pngenc->png_struct_ptr), (png_infopp) NULL,
        (png_infopp) NULL);
  }   
      
  /* non-0 return is from a longjmp inside of libpng */
  if (setjmp (pngenc->png_struct_ptr->jmpbuf) != 0) {
    GST_DEBUG ("returning from longjmp");
    png_destroy_write_struct (&pngenc->png_struct_ptr, &pngenc->png_info_ptr);
    return;
  }

If setting up png_info_ptr fails, there is no return, but png_struct_ptr is
destroyed. That might well result in the next block corrupting memory. Not to
mention that in the first block, a struct allocated by png_create_write_struct
is destroyed with png_destroy_read_block. Note the write Vs read there. The
buffer isn't unref'ed either.
Comment 1 Gergely Nagy 2005-01-08 17:14:33 UTC
Created attachment 35673 [details] [review]
Patch fixing the mentioned problems.

This patch fixes all the problems mentioned in the report.
Comment 2 Ronald Bultje 2005-01-09 01:39:57 UTC
applied, thanks.