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:
Martin Kelly 2016-05-19 09:25:57 -07:00 committed by Sebastian Dröge
parent 537ba5d109
commit 8c236a9f2e

View file

@ -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);