From 3a765e0805688847e36863f5ea4b30c4e19ae6d3 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Fri, 7 Aug 2015 15:43:53 +0100 Subject: [PATCH] facedetect: fix profile loading check Since the profile gchar depends on DEFAULT_FACE_PROFILE, it should never be NULL. Furthermore CascadeClassifier accepts any input, even an empty one, but if the profile fails to load it returns an empty cascade. Check for this instead, and inform the user if there was an Error. --- ext/opencv/gstfacedetect.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ext/opencv/gstfacedetect.cpp b/ext/opencv/gstfacedetect.cpp index ca4710c939..7a24501822 100644 --- a/ext/opencv/gstfacedetect.cpp +++ b/ext/opencv/gstfacedetect.cpp @@ -801,10 +801,13 @@ gst_face_detect_load_profile (GstFaceDetect * filter, gchar * profile) { CascadeClassifier *cascade; - if (profile == NULL) - return NULL; - cascade = new CascadeClassifier (profile); + if (cascade->empty ()) { + GST_ERROR_OBJECT (filter, "Invalid profile file: %s", profile); + delete (cascade); + return NULL; + } + return cascade; }