diff options
author | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2017-08-08 17:21:52 +0200 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2017-08-24 13:04:22 +0200 |
commit | 84870b16dde7c9d4262c01be72b4b69a3dc597ce (patch) | |
tree | e170a798f6c93a9f4d5e38bf01cd785aa0414b73 | |
parent | c1854ec3645f6d46d47f58bb995d9d982e077c4b (diff) |
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.
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiutils_glx.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiutils_glx.c b/gst-libs/gst/vaapi/gstvaapiutils_glx.c index cd9244f0..714dffbd 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; |