mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
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.
This commit is contained in:
parent
98ce1e11bc
commit
129bee3d02
1 changed files with 16 additions and 1 deletions
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue