edgedetect: Don't leak cvImages when caps are changing or the element is reused
authorSebastian Dröge <sebastian@centricular.com>
Sun, 29 Jun 2014 22:05:53 +0000 (00:05 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Sun, 29 Jun 2014 22:05:53 +0000 (00:05 +0200)
ext/opencv/gstedgedetect.c

index 871a57324e0ffedb7c9ba6f9a627985fae380d6d..bb85de4c04e7c679ae6a6c55557f7284d592b4be 100644 (file)
@@ -270,6 +270,13 @@ gst_edge_detect_handle_sink_event (GstPad * pad, GstObject * parent,
       gst_structure_get_int (structure, "width", &width);
       gst_structure_get_int (structure, "height", &height);
 
+      if (filter->cvImage != NULL) {
+        cvReleaseImage (&filter->cvImage);
+        cvReleaseImage (&filter->cvCEdge);
+        cvReleaseImage (&filter->cvGray);
+        cvReleaseImage (&filter->cvEdge);
+      }
+
       filter->cvImage = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
       filter->cvCEdge = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
       filter->cvGray = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 1);