[Kdenlive-devel] [PATCH 05/14] v4lcapture.cpp: free src in the end

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


Found by Coverity:

47QStringList V4lCaptureHandler::getDeviceName(QString input)
 48{
 49
CID 709299: Resource leak (RESOURCE_LEAK)
Calling allocation function "strdup".
Assigning: "src" = storage returned from "strdup(QByteArray(input.toUtf8()).constData())".
 50    char *src = strdup(input.toUtf8().constData());
 51    QString pixelformatdescription;
Variable "src" is not freed or pointed-to in function "open".
 52    int fd = open(src, O_RDWR | O_NONBLOCK);
At conditional (1): "fd < 0" taking the false branch.
...
124    close(fd);
125
126    QStringList result;
At conditional (6): "devName == NULL" taking the true branch.
Variable "src" going out of scope leaks the storage it points to.
127    if (devName == NULL) return result;
128    QString deviceName(devName);
129    result << (deviceName.isEmpty() ? input : deviceName) << pixelformatdescription;
130    return result;
131}
---
 src/v4l/v4lcapture.cpp |    1 +
 1 file changed, 1 insertion(+)

diff --git a/src/v4l/v4lcapture.cpp b/src/v4l/v4lcapture.cpp
index 4b7af82..ada255b 100644
--- a/src/v4l/v4lcapture.cpp
+++ b/src/v4l/v4lcapture.cpp
@@ -122,6 +122,7 @@ QStringList V4lCaptureHandler::getDeviceName(QString input)
         }
     }
     close(fd);
+    delete[] src;
 
     QStringList result;
     if (devName == NULL) return result; 
-- 
1.7.10.4





More information about the Kdenlive mailing list