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 788119 - a52dec: missed unref out buffer in error decoding block
a52dec: missed unref out buffer in error decoding block
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-ugly
1.13.x
Other All
: Normal normal
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-09-25 09:44 UTC by Ponnam Srinivas
Modified: 2017-09-26 08:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
attached patch (769 bytes, text/plain)
2017-09-25 09:44 UTC, Ponnam Srinivas
  Details
attached patch (767 bytes, patch)
2017-09-26 04:45 UTC, Ponnam Srinivas
committed Details | Review

Description Ponnam Srinivas 2017-09-25 09:44:59 UTC
Created attachment 360336 [details]
attached patch

Hi ,
   
   In gst_a52dec_handle_frame . missed unref out buffer in in error decoding.
   This lead to memory leak.
  
   code:
   
   outbuf =
      gst_buffer_new_and_alloc (256 * chans * (SAMPLE_WIDTH / 8) * num_blocks);

  gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
  {
    guint8 *ptr = map.data;
    for (i = 0; i < num_blocks; i++) {
      if (a52_block (a52dec->state)) {
        /* also marks discont */
        GST_AUDIO_DECODER_ERROR (a52dec, 1, STREAM, DECODE, (NULL),
            ("error decoding block %d", i), result);
        if (result != GST_FLOW_OK) {
          gst_buffer_unmap (outbuf, &map);
          goto exit;
        }
      } else {
        gint n, c;
        gint *reorder_map = a52dec->channel_reorder_map;

        for (n = 0; n < 256; n++) {
          for (c = 0; c < chans; c++) {
            ((sample_t *) ptr)[n * chans + reorder_map[c]] =
                a52dec->samples[c * 256 + n];
          }
        }
      }
      ptr += 256 * chans * (SAMPLE_WIDTH / 8);
    }
  }
  
  sol: gst_buffer_unref (outbuf);
  
  Please review and share feedback.
Comment 1 Thiago Sousa Santos 2017-09-26 01:09:09 UTC
Yes. Seems like a leak.

Can you provide a "git format-patch" patch for fixing this issue?

Please put proper name and email on the author field and write a good commit message (see our git log for examples).

Thanks!
Comment 2 Ponnam Srinivas 2017-09-26 04:45:15 UTC
Created attachment 360396 [details] [review]
attached patch

Attached updated patch file. Added proper commit message.
Please review it
Comment 3 Sebastian Dröge (slomo) 2017-09-26 08:14:17 UTC
commit 83d7d2f67a81ad0d99aaf616248a6aa57a1e6f01 (HEAD -> master)
Author: Ponnam Srinivas <p.srinivas@samsung.com>
Date:   Tue Sep 26 10:11:24 2017 +0530

    a52dec: Fix out buffer memory leak in error code path
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788119