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 748412 - tsdemux: possible refcount bug in applying PMT
tsdemux: possible refcount bug in applying PMT
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Reported: 2015-04-24 11:43 UTC by Vincent Penquerc'h
Modified: 2015-05-18 15:15 UTC
See Also:
GNOME target: ---
GNOME version: ---

fix refcounting when applying a new PMT (1.28 KB, patch)
2015-04-24 12:00 UTC, Vincent Penquerc'h
committed Details | Review

Description Vincent Penquerc'h 2015-04-24 11:43:19 UTC
In gst/mpegtsdemux/mpegtsbase.c, apply_pmt:

   /* If the current program is active, this means we have a new program */
   if (old_program->active) {
     old_program = mpegts_base_steal_program (base, program_number);
     program = mpegts_base_new_program (base, program_number, section->pid);
     g_hash_table_insert (base->programs,
         GINT_TO_POINTER (program_number), program);

This will create a new program with patcount 0. When a new PAT is encountered, if it still references this program number, the patcount will be both incremented and decremented, which will end up deleting that program.

File with this PMT change:

Setting the patcount to 1 when creating this new program makes it survive, but seems wrong, as the program number is not found in the existing PAT by:

program = mpegts_base_get_program (base, program_number);

This seems to be because the program number was just "stolen" from the hash table just before, for reasons I have no idea about.

Maybe the patcount should be copied from old_program to the new program instead ? I've no idea what the intent of this swapping code is so I'm not sure.
Comment 1 Vincent Penquerc'h 2015-04-24 12:00:14 UTC
Created attachment 302289 [details] [review]
fix refcounting when applying a new PMT

I think copying the refcount is the correct thing to do, given the new program shadows the one stolen from the hash table.
It works with the sample file (till next problem anyway).
Needs someone with MPEG-TS knowledge to double check sanity.