From f255422ec22c33ed9565269c54ba5dfaa11d3834 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Wed, 9 Apr 2014 14:13:46 +0100 Subject: [PATCH] mpegtsdemux: catch prev-not-found when inserting in the group list While this probably should never happen if callers are well behaved, this avoids a crash if it does. With a warning about it. Unsure if it'd be better to not add at all, but it should not happen... Coverity 1139713 --- gst/mpegtsdemux/mpegtspacketizer.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c index 4b7f07bb1e..088028ce9c 100644 --- a/gst/mpegtsdemux/mpegtspacketizer.c +++ b/gst/mpegtsdemux/mpegtspacketizer.c @@ -1720,12 +1720,18 @@ _insert_group_after (MpegTSPCR * pcrtable, PCROffsetGroup * group, break; } } - toinsert = g_list_append (NULL, group); - toinsert->next = nextlist; - toinsert->prev = prevlist; - prevlist->next = toinsert; - if (nextlist) - nextlist->prev = toinsert; + if (!prevlist) { + /* The non NULL prev given isn't in the list */ + GST_WARNING ("Request to insert before a group which isn't in the list"); + pcrtable->groups = g_list_prepend (pcrtable->groups, group); + } else { + toinsert = g_list_append (NULL, group); + toinsert->next = nextlist; + toinsert->prev = prevlist; + prevlist->next = toinsert; + if (nextlist) + nextlist->prev = toinsert; + } } }