From: Víctor Manuel Jáquez Leal Date: Tue, 8 Aug 2017 15:21:52 +0000 (+0200) Subject: libs: utils: glx: check return value X-Git-Tag: 1.19.3~503^2~900 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fbffda4e2f75ef31080f3a8480246018a006300f;p=platform%2Fupstream%2Fgstreamer.git libs: utils: glx: check return value Coverity scan bug: If the function returns an error value, the error value may be mistaken for a normal value. Function sscanf returns the number of assignations done. Validate this return value with the number of expected variables to match. --- diff --git a/gst-libs/gst/vaapi/gstvaapiutils_glx.c b/gst-libs/gst/vaapi/gstvaapiutils_glx.c index cd9244f..714dffb 100644 --- a/gst-libs/gst/vaapi/gstvaapiutils_glx.c +++ b/gst-libs/gst/vaapi/gstvaapiutils_glx.c @@ -1163,7 +1163,7 @@ GstVaapiGLApi gl_get_current_api (guint * major, guint * minor) { const gchar *version; - gint maj, min, n; + gint maj, min, n, sret; GstVaapiGLApi ret = (1 << 31); while (ret != GST_VAAPI_GL_API_NONE) { @@ -1181,7 +1181,9 @@ gl_get_current_api (guint * major, guint * minor) if (n < 13) goto next; - sscanf (&version[10], "%d.%d", &maj, &min); + sret = sscanf (&version[10], "%d.%d", &maj, &min); + if (sret != 2) + goto next; if (maj <= 0 || min < 0) goto next; @@ -1196,7 +1198,9 @@ gl_get_current_api (guint * major, guint * minor) goto next; } else { - sscanf (version, "%d.%d", &maj, &min); + sret = sscanf (version, "%d.%d", &maj, &min); + if (sret != 2) + goto next; if (maj <= 0 || min < 0) goto next;