opencv: facedetect: check pointer before using it

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
This commit is contained in:
Luis de Bethencourt 2015-08-05 11:39:01 +01:00
parent ca52600ccb
commit cc8af753b9

View 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);
}
cascade = new CascadeClassifier (profile);
return cascade;
}