From c2ac57f6c970ab6129507bb04bcea47a693ab17f Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Sun, 10 Apr 2022 10:55:02 +1000 Subject: [PATCH] subparse: don't try to index string with -1 If the len of the string turns out to be 0, str[len - 1] resolved to str[-1] which is not a good idea. Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=46543 Part-of: --- subprojects/gst-plugins-base/gst/subparse/gstsubparseelement.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-base/gst/subparse/gstsubparseelement.c b/subprojects/gst-plugins-base/gst/subparse/gstsubparseelement.c index 7b40fd5..72af499 100644 --- a/subprojects/gst-plugins-base/gst/subparse/gstsubparseelement.c +++ b/subprojects/gst-plugins-base/gst/subparse/gstsubparseelement.c @@ -187,7 +187,7 @@ gst_sub_parse_data_format_autodetect (gchar * match_str) if (sscanf (str, "[%u:%02u.%02u]", &n1, &n2, &n3) == 3 || sscanf (str, "[%u:%02u.%03u]", &n1, &n2, &n3) == 3) { all_lines_good = TRUE; - } else if (str[len - 1] == ']' && strchr (str, ':') != NULL) { + } else if (len > 0 && str[len - 1] == ']' && strchr (str, ':') != NULL) { all_lines_good = TRUE; } else { all_lines_good = FALSE; -- 2.7.4