GNOME Bugzilla – Bug 766638
ahc: fix possible NULL deref
Last modified: 2016-05-25 08:09:48 UTC
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 logging only if params has been allocated.
Created attachment 328163 [details] [review] ahc: fix possible NULL deref
now I got why you added https://bugzilla.gnome.org/show_bug.cgi?id=766637. I think it would be better something like, if (!object) { GST_WARNING ("android.hardware.Camera.getParameter is NULL"); return NULL; } params = g_slice_new0 (GstAHCParameters); params->object = gst_amc_jni_object_ref (env, object); .... instead of checking the object is not null.
Comment on attachment 328163 [details] [review] ahc: fix possible NULL deref That suggestion seems a bit cleaner indeed
Created attachment 328224 [details] [review] v2-0001-ahc-fix-potential-NULL-deref.patch
I agree with the suggestion, and my attached v2 patch implements it.
commit 8c236a9f2e681fa4756a9781b35fc53c1380cf61 Author: Martin Kelly <martin@surround.io> Date: Thu May 19 09:25:57 2016 -0700 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