diff options
author | Chris Bass <floobleflam@gmail.com> | 2017-04-19 16:06:52 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-04-19 18:28:31 +0100 |
commit | 129bee3d0283b907dc26f5ab621b3b16f50ffab5 (patch) | |
tree | 4f19dcefbcc7ae3828698eb81132213a2fc59acf /ext/ttml | |
parent | 98ce1e11bc3da9d3b383a224e28a7a9b61ca7ad5 (diff) | |
download | gstreamer-plugins-bad-129bee3d0283b907dc26f5ab621b3b16f50ffab5.tar.gz |
ttmlrender: Fix potential problem identified by clang
Clang's static analyser found potential code paths in which variables
were being used in comparisons when uninitialised. Fix by properly
handling out-of-range value returned by gst_ttml_get_element_index.
Diffstat (limited to 'ext/ttml')
-rw-r--r-- | ext/ttml/gstttmlrender.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/ext/ttml/gstttmlrender.c b/ext/ttml/gstttmlrender.c index b6a63b5bf..6c1689454 100644 --- a/ext/ttml/gstttmlrender.c +++ b/ext/ttml/gstttmlrender.c @@ -1841,7 +1841,9 @@ gst_ttml_render_split_block (UnifiedBlock * block, GPtrArray * char_ranges) gint i; for (i = 0; i < char_ranges->len; ++i) { - gint index, first_offset, last_offset; + gint index; + gint first_offset = 0; + gint last_offset = 0; CharRange *range = g_ptr_array_index (char_ranges, i); UnifiedBlock *clone = gst_ttml_render_unified_block_copy (block); UnifiedElement *ue; @@ -1855,6 +1857,12 @@ gst_ttml_render_split_block (UnifiedBlock * block, GPtrArray * char_ranges) GST_CAT_LOG (ttmlrender_debug, "Last char in range is in element %d", index); + if (index < 0) { + GST_CAT_WARNING (ttmlrender_debug, "Range end not found in block text."); + gst_ttml_render_unified_block_free (clone); + continue; + } + /* Remove elements that are after the one that contains the range end. */ GST_CAT_LOG (ttmlrender_debug, "There are %d elements in cloned block.", gst_ttml_render_unified_block_element_count (clone)); @@ -1869,6 +1877,13 @@ gst_ttml_render_split_block (UnifiedBlock * block, GPtrArray * char_ranges) GST_CAT_LOG (ttmlrender_debug, "First char in range is in element %d", index); + if (index < 0) { + GST_CAT_WARNING (ttmlrender_debug, + "Range start not found in block text."); + gst_ttml_render_unified_block_free (clone); + continue; + } + /* Remove elements that are before the one that contains the range start. */ while (index > 0) { GST_CAT_LOG (ttmlrender_debug, "Removing first element in cloned block"); |