opencv: facedetect: check pointer before using it
authorLuis de Bethencourt <luis@debethencourt.com>
Wed, 5 Aug 2015 10:39:01 +0000 (11:39 +0100)
committerLuis de Bethencourt <luis@debethencourt.com>
Wed, 5 Aug 2015 10:39:03 +0000 (11:39 +0100)
Check if profile is NULL before dereferencing it with new. Also, new will
never return NULL; if allocation fails, a std::bad_alloc exception will be
thrown instead. Remove check for a NULL return.

CID #1315258

ext/opencv/gstfacedetect.cpp

index 392846b..12c6f4c 100644 (file)
@@ -803,14 +803,12 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
 static CascadeClassifier *
 gst_face_detect_load_profile (GstFaceDetect * filter, gchar * profile)
 {
-  CascadeClassifier *cascade = new CascadeClassifier (profile);
+  CascadeClassifier *cascade;
 
   if (profile == NULL)
-    return NULL;
-  if (!cascade) {
-    GST_WARNING_OBJECT (filter, "Couldn't load Haar classifier cascade: %s.",
-        profile);
-  }
+     return NULL;
+
+  cascade = new CascadeClassifier (profile);
   return cascade;
 }