summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Kelly <martin@surround.io>2016-05-19 09:25:57 -0700
committerSebastian Dröge <sebastian@centricular.com>2016-05-20 09:16:28 +0300
commit8c236a9f2e681fa4756a9781b35fc53c1380cf61 (patch)
treee693ad33d213b64b126d902b3a301a39d2d00c21 /sys
parent537ba5d1091baa3ac7273eabf4b4d60b37304fce (diff)
downloadgstreamer-plugins-bad-8c236a9f2e681fa4756a9781b35fc53c1380cf61.tar.gz
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
Diffstat (limited to 'sys')
-rw-r--r--sys/androidmedia/gst-android-hardware-camera.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/androidmedia/gst-android-hardware-camera.c b/sys/androidmedia/gst-android-hardware-camera.c
index 6b32ed5ce..c22129f09 100644
--- a/sys/androidmedia/gst-android-hardware-camera.c
+++ b/sys/androidmedia/gst-android-hardware-camera.c
@@ -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);