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 619943 - [jpegenc] Crash if playing -> setcaps -> ready -> setcaps
[jpegenc] Crash if playing -> setcaps -> ready -> setcaps
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other All
: Normal blocker
: 0.10.23
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-05-28 13:42 UTC by Thiago Sousa Santos
Modified: 2010-05-28 14:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
jpegenc: Keep variables in sane state after _reset (840 bytes, patch)
2010-05-28 13:46 UTC, Thiago Sousa Santos
committed Details | Review

Description Thiago Sousa Santos 2010-05-28 13:42:29 UTC
Jpegenc will crash if the following sequence of actions take place:

1) Create (jpegenc->row[x][y] are NULL)
2) Set to playing
3) set_caps takes place and calls '_resync'

Piece of code form _resync:
[code]
    if (!jpegenc->planar) {
      for (j = 0; j < jpegenc->v_max_samp * DCTSIZE; j++) {
        jpegenc->row[i][j] = g_realloc (jpegenc->row[i][j], width);
        jpegenc->line[i][j] = jpegenc->row[i][j];
      }
    }
[/code]

4) Everything goes fine, you set it to READY
* At this point _reset is called

Piece of code form _reset:
[code]
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 4 * DCTSIZE; j++) {
      g_free (enc->row[i][j]);
    }
  }
[/code]

'row' is freed and non-null (oh oh)

5) set it to playing again
6) set_caps is called... crash on g_realloc! (double free)

Patch follows.
Comment 1 Thiago Sousa Santos 2010-05-28 13:46:21 UTC
Created attachment 162218 [details] [review]
jpegenc: Keep variables in sane state after _reset

When reseting, keep 'row' variables at a sane state after
freeing to avoid it being freed again on _resync realloc
when the element is reused.

Fixes #619943
Comment 2 Thiago Sousa Santos 2010-05-28 14:03:14 UTC
Fixed.

commit e0c49a7590b1d554a5e6059edac125bf36b8f4d8
Author: Thiago Santos <thiago.sousa.santos@collabora.co.uk>
Date:   Fri May 28 10:43:36 2010 -0300

    jpegenc: Keep variables in sane state after _reset
    
    When reseting, keep 'row' variables at a sane state after
    freeing to avoid it being freed again on _resync realloc
    when the element is reused.
    
    Fixes #619943