mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11: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);
|
||||
return NULL;
|
||||
}
|
||||
if (!object) {
|
||||
GST_WARNING ("android.hardware.Camera.getParameter is NULL");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (object) {
|
||||
params = g_slice_new0 (GstAHCParameters);
|
||||
params->object = gst_amc_jni_object_ref (env, object);
|
||||
gst_amc_jni_object_local_unref (env, object);
|
||||
if (!params->object) {
|
||||
GST_ERROR ("Failed to create global reference");
|
||||
(*env)->ExceptionClear (env);
|
||||
g_slice_free (GstAHCParameters, params);
|
||||
return NULL;
|
||||
}
|
||||
params = g_slice_new0 (GstAHCParameters);
|
||||
params->object = gst_amc_jni_object_ref (env, object);
|
||||
gst_amc_jni_object_local_unref (env, object);
|
||||
if (!params->object) {
|
||||
GST_ERROR ("Failed to create global reference");
|
||||
(*env)->ExceptionClear (env);
|
||||
g_slice_free (GstAHCParameters, params);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GST_DEBUG ("return parameters %p", params->object);
|
||||
|
|
Loading…
Reference in a new issue