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,8 +2284,11 @@ 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);
@ -2295,7 +2298,6 @@ gst_ah_camera_get_parameters (GstAHCamera * self)
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);