[Kdenlive-devel] [PATCH 14/16] renderer.cpp: check for null pointers

Mikko Rapeli mikko.rapeli at iki.fi
Fri Aug 10 12:17:15 UTC 2012


Fixes Coverity CID 709292 and 709293:
Dereference after null check (FORWARD_NULL) [select defect]
1917    if (original == NULL || clip == NULL) {
1918        kDebug() << "// ERROR GRABBING CLIP AFTER SPLIT";
1919    }
1920    Mlt::Service clipService(original->get_service());
1921    Mlt::Service dupService(clip->get_service());
1922    delete original;
1923    delete clip;
---
 src/renderer.cpp |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/renderer.cpp b/src/renderer.cpp
index 5effeb8..6077b56 100644
--- a/src/renderer.cpp
+++ b/src/renderer.cpp
@@ -1914,11 +1914,21 @@ void Render::mltCutClip(int track, GenTime position)
     Mlt::Producer *original = trackPlaylist.get_clip_at(clipStart);
     Mlt::Producer *clip = trackPlaylist.get_clip_at(cutPos);
 
-    if (original == NULL || clip == NULL) {
+    Mlt::Service clipService;
+    Mlt::Service dupService;
+    if (original)
+        clipService = Mlt::Service(original->get_service());
+    else
+        clipService = Mlt::Service();
+
+    if (clip)
+        dupService = Mlt::Service(clip->get_service());
+    else
+        dupService = Mlt::Service();
+
+    if (original == NULL || clip == NULL)
         kDebug() << "// ERROR GRABBING CLIP AFTER SPLIT";
-    }
-    Mlt::Service clipService(original->get_service());
-    Mlt::Service dupService(clip->get_service());
+
     delete original;
     delete clip;
     int ct = 0;
-- 
1.7.10.4





More information about the Kdenlive mailing list