[Kdenlive-devel] [PATCH 07/14] jogshuttle.cpp: close() on error path

Mikko Rapeli mikko.rapeli at iki.fi
Sun Jul 22 18:28:15 UTC 2012


Found by Coverity:

CID 709297: Resource leak (RESOURCE_LEAK)
Calling opening function "open".
Assigning: "fd" = handle returned from "open((char *)QByteArray(this->m_device.toUtf8()).data(), 0)".
 89    const int fd = KDE_open((char *) m_device.toUtf8().data(), O_RDONLY);
At conditional (1): "fd < 0" taking the false branch.
 90    if (fd < 0) {
 91        fprintf(stderr, "Can't open Jog Shuttle FILE DESCRIPTOR\n");
 92        return;;
 93    }
 94    EV ev;
 95
At conditional (2): "ioctl(fd, 1074021776UL, 1) < 0" taking the true branch.
Variable "fd" is not closed or saved in function "ioctl".
 96    if (ioctl(fd, EVIOCGRAB, 1) < 0) {
 97        fprintf(stderr, "Can't get exclusive access on  Jog Shuttle FILE DESCRIPTOR\n");
Handle variable "fd" going out of scope leaks the handle.
 98        return;;
 99    }
---
 src/jogshuttle.cpp |    1 +
 1 file changed, 1 insertion(+)

diff --git a/src/jogshuttle.cpp b/src/jogshuttle.cpp
index b5dd0e8..8446076 100644
--- a/src/jogshuttle.cpp
+++ b/src/jogshuttle.cpp
@@ -95,6 +95,7 @@ void ShuttleThread::run()
 
     if (ioctl(fd, EVIOCGRAB, 1) < 0) {
         fprintf(stderr, "Can't get exclusive access on  Jog Shuttle FILE DESCRIPTOR\n");
+        close(fd);
         return;;
     }
 
-- 
1.7.10.4





More information about the Kdenlive mailing list