mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
ahc: fix potential NULL deref
This bug was found via cppcheck static analysis. If android.hardware.Camera.getParameters returns NULL, then object will be NULL, and we won't allocate params. This means that the GST_DEBUG statement referencing params->object will be invalid. Fix this by exiting early if android.hardware.Camera.getParameters returns NULL. https://bugzilla.gnome.org/show_bug.cgi?id=766638
This commit is contained in:
parent
537ba5d109
commit
8c236a9f2e
1 changed files with 12 additions and 10 deletions
|
@ -2284,17 +2284,19 @@ gst_ah_camera_get_parameters (GstAHCamera * self)
|
||||||
g_clear_error (&err);
|
g_clear_error (&err);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (!object) {
|
||||||
|
GST_WARNING ("android.hardware.Camera.getParameter is NULL");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (object) {
|
params = g_slice_new0 (GstAHCParameters);
|
||||||
params = g_slice_new0 (GstAHCParameters);
|
params->object = gst_amc_jni_object_ref (env, object);
|
||||||
params->object = gst_amc_jni_object_ref (env, object);
|
gst_amc_jni_object_local_unref (env, object);
|
||||||
gst_amc_jni_object_local_unref (env, object);
|
if (!params->object) {
|
||||||
if (!params->object) {
|
GST_ERROR ("Failed to create global reference");
|
||||||
GST_ERROR ("Failed to create global reference");
|
(*env)->ExceptionClear (env);
|
||||||
(*env)->ExceptionClear (env);
|
g_slice_free (GstAHCParameters, params);
|
||||||
g_slice_free (GstAHCParameters, params);
|
return NULL;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG ("return parameters %p", params->object);
|
GST_DEBUG ("return parameters %p", params->object);
|
||||||
|
|
Loading…
Reference in a new issue