diff options
author | Jan Schmidt <jan@centricular.com> | 2016-03-12 03:00:14 +1100 |
---|---|---|
committer | Jan Schmidt <jan@centricular.com> | 2016-03-12 03:32:32 +1100 |
commit | 6de7f0c0fa77f438f4a66f58a8598b02a1292bc5 (patch) | |
tree | 7be6486ddff95a5fceab5c4115c625f6bdf70b76 /gst/mpegtsdemux | |
parent | 92f4eb45abbe5ada79d8752b58949f2a73af6d90 (diff) |
mpegts: Don't leave freed programs in the hash table
When the sub-class claims a program for later freeing, make
sure it's not left in the hash table, or it can cause crashes on shutdown.
Make sure tsdemux frees any program it has kept around at shutdown
if it wasn't freed already.
https://bugzilla.gnome.org/show_bug.cgi?id=763503
Diffstat (limited to 'gst/mpegtsdemux')
-rw-r--r-- | gst/mpegtsdemux/mpegtsbase.c | 10 | ||||
-rw-r--r-- | gst/mpegtsdemux/tsdemux.c | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/gst/mpegtsdemux/mpegtsbase.c b/gst/mpegtsdemux/mpegtsbase.c index d63122f7c..eb16aac39 100644 --- a/gst/mpegtsdemux/mpegtsbase.c +++ b/gst/mpegtsdemux/mpegtsbase.c @@ -816,6 +816,11 @@ mpegts_base_apply_pat (MpegTSBase * base, GstMpegtsSection * section) if (klass->can_remove_program (base, program)) { mpegts_base_deactivate_program (base, program); mpegts_base_remove_program (base, patp->program_number); + } else { + /* sub-class now owns the program and must call + * mpegts_base_deactivate_and_free_program later */ + g_hash_table_steal (base->programs, + GINT_TO_POINTER ((gint) patp->program_number)); } /* FIXME: when this happens it may still be pmt pid of another * program, so setting to False may make it go through expensive @@ -891,6 +896,11 @@ mpegts_base_apply_pmt (MpegTSBase * base, GstMpegtsSection * section) if (klass->can_remove_program (base, old_program)) { mpegts_base_deactivate_program (base, old_program); mpegts_base_free_program (old_program); + } else { + /* sub-class now owns the program and must call + * mpegts_base_deactivate_and_free_program later */ + g_hash_table_steal (base->programs, + GINT_TO_POINTER ((gint) old_program->program_number)); } initial_program = FALSE; } else diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index 8eaf9a798..1a51ac901 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -407,6 +407,11 @@ gst_ts_demux_reset (MpegTSBase * base) demux->global_tags = NULL; } + if (demux->previous_program) { + mpegts_base_deactivate_and_free_program (base, demux->previous_program); + demux->previous_program = NULL; + } + demux->have_group_id = FALSE; demux->group_id = G_MAXUINT; |