From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:38
|
Found by Coverity: 37MeltJob::MeltJob(CLIPTYPE cType, const QString &id, QStringList parameters) : AbstractClipJob(MLTJOB, cType, id, parameters), 38 m_producer(NULL), 39 m_profile(NULL), 40 m_consumer(NULL), 41 m_length(0) 42{ 43 jobStatus = JOBWAITING; 44 m_params = parameters; 45 description = i18n("Process clip"); 46 QString consum = m_params.at(5); At conditional (1): "consum.contains(QString const(":"), _ZN2Qt13CaseSensitiveE).operator void const *()" taking the true branch. 47 if (consum.contains(":")) m_dest = consum.section(":", 1); CID 709312: Uninitialized pointer field (UNINIT_CTOR) Non-static class member ""m_showFrameEvent"" is not initialized in this constructor nor in any functions that it calls. 48} --- src/projecttree/meltjob.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/projecttree/meltjob.cpp b/src/projecttree/meltjob.cpp index 0ec44cd..19d29e1 100644 --- a/src/projecttree/meltjob.cpp +++ b/src/projecttree/meltjob.cpp @@ -38,6 +38,7 @@ MeltJob::MeltJob(CLIPTYPE cType, const QString &id, QStringList parameters) : Ab m_producer(NULL), m_profile(NULL), m_consumer(NULL), + m_showFrameEvent(NULL), m_length(0) { jobStatus = JOBWAITING; -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:39
|
Hello, Like mlt, kdenlive is now part of Coverity open source scan project. Getting sources scanned is basically a local build with Coverity wrappers followed by an upload of the data to Coverity servers ( http://scan.coverity.com/self-build/ ). After that the static analysis findings can be browsed in their web based interface together with the source code. Browsing requires an account and rights to the kdenlive project on the Coverity servers. Me and JB can add people there if anyone is interested. These Coverity fixes were developed on top of my previous krazy fixes and tested briefly with my own editing projects. Mikko Rapeli (14): audioEnvelope.cpp: initialize Mean and StdDev to zero audioInfo.cpp: initialize m_producer pointer meltjob.cpp: initialize m_showFrameEvent scopemanager.h: initialize pointers v4lcapture.cpp: free src in the end abstractmonitor.h: initialize analyseAudio to false jogshuttle.cpp: close() on error path keyframehelper.cpp: free allocated memory kis_curve_widget_p.h: initialize private data definitions.h: initialize MltVideoProfile titledocument.cpp: initialize variables definitions.h: initialize ItemInfo definitions.h: initialize TrackInfo definitions.h: initialize TransitionInfo src/abstractmonitor.h | 2 +- src/definitions.h | 34 ++++++++++++++++++++++++++++++---- src/jogshuttle.cpp | 1 + src/keyframehelper.cpp | 2 ++ src/kis_curve_widget_p.h | 17 +++++++++++++++++ src/lib/audio/audioEnvelope.cpp | 2 ++ src/lib/audio/audioInfo.cpp | 3 ++- src/projecttree/meltjob.cpp | 1 + src/scopes/scopemanager.h | 12 ++++++++++-- src/titledocument.cpp | 2 ++ src/v4l/v4lcapture.cpp | 1 + 11 files changed, 69 insertions(+), 8 deletions(-) -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:38
|
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 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:40
|
Found by Coverity: 60TitleDocument::TitleDocument() 61{ 62 m_scene = NULL; CID 709315: Uninitialized scalar field (UNINIT_CTOR) Non-static class member ""m_height"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_width"" is not initialized in this constructor nor in any functions that it calls. 63} --- src/titledocument.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/titledocument.cpp b/src/titledocument.cpp index dc198f2..95aff61 100644 --- a/src/titledocument.cpp +++ b/src/titledocument.cpp @@ -60,6 +60,8 @@ QByteArray fileToByteArray(const QString& filename) TitleDocument::TitleDocument() { m_scene = NULL; + m_width = 0; + m_height = 0; } void TitleDocument::setScene(QGraphicsScene* _scene, int width, int height) -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:39
|
Found by Coverity: At conditional (1): "this->m_length > 0" taking the true branch. 33 if (m_length > 0) { 34 Q_ASSERT(m_length+m_offset <= m_envelopeSize); 35 m_envelopeSize = m_length; 36 } CID 709310: Uninitialized scalar field (UNINIT_CTOR) Non-static class member ""m_envelopeMean"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_envelopeStdDev"" is not initialized in this constructor nor in any functions that it calls. 37} --- src/lib/audio/audioEnvelope.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/audio/audioEnvelope.cpp b/src/lib/audio/audioEnvelope.cpp index 203806f..00bda00 100644 --- a/src/lib/audio/audioEnvelope.cpp +++ b/src/lib/audio/audioEnvelope.cpp @@ -22,6 +22,8 @@ AudioEnvelope::AudioEnvelope(Mlt::Producer *producer, int offset, int length) : m_length(length), m_envelopeSize(producer->get_length()), m_envelopeMax(0), + m_envelopeMean(0), + m_envelopeStdDev(0), m_envelopeStdDevCalculated(false), m_envelopeIsNormalized(false) { -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:40
|
Found by Coverity: CID 709305: Uninitialized scalar variable (UNINIT) Declaring variable "info". 191 ItemInfo info; Using uninitialized value "info": field "info".track is uninitialized when calling "EffectStackEdit::transferParamDesc(QDomElement const &, ItemInfo, bool)". [show details] 192 m_effectEdit->transferParamDesc(QDomElement(), info, false); 193 } 194} --- src/definitions.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/definitions.h b/src/definitions.h index 1e03945..a48306e 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -83,7 +83,8 @@ struct TrackInfo { typedef QMap<QString, QString> stringMap; typedef QMap <int, QMap <int, QByteArray> > audioByteArray; -struct ItemInfo { +class ItemInfo { +public: /** startPos is the position where the clip starts on the track */ GenTime startPos; /** endPos is the duration where the clip ends on the track */ @@ -93,6 +94,7 @@ struct ItemInfo { /** cropDuration is the duration of the clip */ GenTime cropDuration; int track; + ItemInfo() : track(0) {}; }; struct TransitionInfo { -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:40
|
Just in case someone uses the class/struct without setting all of the variables. --- src/definitions.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/definitions.h b/src/definitions.h index a48306e..3d8ce6a 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -70,7 +70,8 @@ enum TRACKTYPE { AUDIOTRACK = 0, VIDEOTRACK = 1 }; enum CLIPJOBSTATUS { NOJOB = 0, JOBWAITING = -1, JOBWORKING = -2, JOBDONE = -3, JOBCRASHED = -4, JOBABORTED = -5}; -struct TrackInfo { +class TrackInfo { +public: TRACKTYPE type; QString trackName; bool isMute; @@ -78,6 +79,12 @@ struct TrackInfo { bool isLocked; EffectsList effectsList; int duration; + TrackInfo() : + type(VIDEOTRACK), + isMute(0), + isBlind(0), + isLocked(0), + duration(0) {}; }; typedef QMap<QString, QString> stringMap; -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:40
|
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 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:41
|
Just in case someone uses the class/struct without setting all of the variables. --- src/definitions.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/definitions.h b/src/definitions.h index 3d8ce6a..b663fc6 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -104,7 +104,8 @@ public: ItemInfo() : track(0) {}; }; -struct TransitionInfo { +class TransitionInfo { +public: /** startPos is the position where the clip starts on the track */ GenTime startPos; /** endPos is the duration where the clip ends on the track */ @@ -115,6 +116,10 @@ struct TransitionInfo { int a_track; /** Does the user request for a special a_track */ bool forceTrack; + TransitionInfo() : + b_track(0), + a_track(0), + forceTrack(0) {}; }; class MltVideoProfile { -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:44
|
Coverity says: 82 for (int i = 0; i < m_extraGeometries.count(); i++) { At conditional (1): "<new init>@dim2 < 5U" taking the true branch. At conditional (2): "<new init>@dim2 < 5U" taking the true branch. At conditional (3): "<new init>@dim2 < 5U" taking the false branch. CID 709298: Resource leak (RESOURCE_LEAK) Calling allocation function "operator new(unsigned int)". Assigning: "item2" = storage returned from "new Mlt::GeometryItem({{, , , , , , , , {}}})". 83 Mlt::GeometryItem *item2 = new Mlt::GeometryItem(); At conditional (4): "this->m_extraGeometries.at(i)->next_key(item, mousePos) == 0" taking the false branch. 84 if (m_extraGeometries.at(i)->next_key(item, mousePos) == 0) { 85 item2->x(item.x()); 86 item2->frame(item.frame()); 87 m_extraMovingItems.append(item2); 88 } Variable "item2" going out of scope leaks the storage it points to. 89 } --- src/keyframehelper.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/keyframehelper.cpp b/src/keyframehelper.cpp index 5a8de19..a1c9af9 100644 --- a/src/keyframehelper.cpp +++ b/src/keyframehelper.cpp @@ -85,6 +85,8 @@ void KeyframeHelper::mousePressEvent(QMouseEvent * event) item2->x(item.x()); item2->frame(item.frame()); m_extraMovingItems.append(item2); + } else { + delete(item2); } } -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:50
|
Found by Coverity: 41 /* Dragging variables */ CID 709309: Uninitialized scalar field (UNINIT_CTOR) ... CID 709309: Uninitialized pointer field (UNINIT_CTOR) Class member declaration for ""m_pixmapCache"". 61 QPixmap *m_pixmapCache; 62 63 /* In/Out controls */ Class member declaration for ""m_intIn"". 64 QSpinBox *m_intIn; Class member declaration for ""m_intOut"". 65 ... 131KisCurveWidget::Private::Private(KisCurveWidget *parent) 132{ 133 m_curveWidget = parent; Non-static class member ""m_draggedAwayPointIndex"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_grabOffsetX"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_grabOffsetY"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_grabOriginalX"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_grabOriginalY"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_grab_point_index"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_guideVisible"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_inOutMax"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_inOutMin"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_maxPoints"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_pixmapDirty"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_readOnlyMode"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_splineDirty"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_state"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_intIn"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_intOut"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""m_pixmapCache"" is not initialized in this constructor nor in any functions that it calls. 134} --- src/kis_curve_widget_p.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/kis_curve_widget_p.h b/src/kis_curve_widget_p.h index e3895f7..035742d 100644 --- a/src/kis_curve_widget_p.h +++ b/src/kis_curve_widget_p.h @@ -131,6 +131,23 @@ public: KisCurveWidget::Private::Private(KisCurveWidget *parent) { m_curveWidget = parent; + m_grab_point_index = 0; + m_grabOffsetX = 0; + m_grabOffsetY = 0; + m_grabOriginalX = 0; + m_grabOriginalY = 0; + m_draggedAwayPointIndex = 0; + m_readOnlyMode = 0; + m_guideVisible = 0; + m_splineDirty = 0; + m_pixmapDirty = 0; + m_pixmapCache = NULL; + m_intIn = NULL; + m_intOut = NULL; + m_inOutMin = 0; + m_inOutMax = 0; + m_state = ST_NORMAL; + m_maxPoints = 0; } KisCurveWidget::Private::~Private() -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:50
|
Found by Coverity: 18AudioInfo::AudioInfo(Mlt::Producer *producer) 19{ 20 // Since we already receive an MLT producer, we do not need to initialize MLT: 21 // Mlt::Factory::init(NULL); 22 23 // Get the number of streams and add the information of each of them if it is an audio stream. 24 int streams = atoi(producer->get("meta.media.nb_streams")); At conditional (1): "i < streams" taking the true branch. At conditional (3): "i < streams" taking the true branch. At conditional (5): "i < streams" taking the false branch. 25 for (int i = 0; i < streams; i++) { 26 QByteArray propertyName = QString("meta.media.%1.stream.type").arg(i).toLocal8Bit(); 27 At conditional (2): "strcmp("audio", producer->get(propertyName.data())) == 0" taking the true branch. At conditional (4): "strcmp("audio", producer->get(propertyName.data())) == 0" taking the true branch. 28 if (strcmp("audio", producer->get(propertyName.data())) == 0) { 29 m_list << new AudioStreamInfo(producer, i); 30 } 31 32 } CID 709311: Uninitialized pointer field (UNINIT_CTOR) Non-static class member ""m_producer"" is not initialized in this constructor nor in any functions that it calls. 33} --- src/lib/audio/audioInfo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/audio/audioInfo.cpp b/src/lib/audio/audioInfo.cpp index c467a96..c210ef7 100644 --- a/src/lib/audio/audioInfo.cpp +++ b/src/lib/audio/audioInfo.cpp @@ -15,7 +15,8 @@ #include <iostream> #include <cstdlib> -AudioInfo::AudioInfo(Mlt::Producer *producer) +AudioInfo::AudioInfo(Mlt::Producer *producer) : +m_producer(NULL) { // Since we already receive an MLT producer, we do not need to initialize MLT: // Mlt::Factory::init(NULL); -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:50
|
Found by Coverity: 31class ScopeManager : QObject 32{ 33 Q_OBJECT 34 35 struct GfxScopeData { CID 709313: Uninitialized pointer field (UNINIT_CTOR) Class member declaration for ""scope"". 36 AbstractGfxScopeWidget *scope; Class member declaration for ""scopeDockWidget"". 37 QDockWidget *scopeDockWidget; 38 bool singleFrameRequested; Non-static class member ""scope"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""scopeDockWidget"" is not initialized in this constructor nor in any functions that it calls. 39 GfxScopeData() { singleFrameRequested = false; } 40 }; 41 42 struct AudioScopeData { CID 709314: Uninitialized pointer field (UNINIT_CTOR) Class member declaration for ""scope"". 43 AbstractAudioScopeWidget *scope; Class member declaration for ""scopeDockWidget"". 44 QDockWidget *scopeDockWidget; 45 bool singleFrameRequested; Non-static class member ""scope"" is not initialized in this constructor nor in any functions that it calls. Non-static class member ""scopeDockWidget"" is not initialized in this constructor nor in any functions that it calls. 46 AudioScopeData() { singleFrameRequested = false; } 47 }; --- src/scopes/scopemanager.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/scopes/scopemanager.h b/src/scopes/scopemanager.h index 3ad8320..79b45e1 100644 --- a/src/scopes/scopemanager.h +++ b/src/scopes/scopemanager.h @@ -36,14 +36,22 @@ class ScopeManager : QObject AbstractGfxScopeWidget *scope; QDockWidget *scopeDockWidget; bool singleFrameRequested; - GfxScopeData() { singleFrameRequested = false; } + GfxScopeData() { + scope = NULL; + scopeDockWidget = NULL; + singleFrameRequested = false; + } }; struct AudioScopeData { AbstractAudioScopeWidget *scope; QDockWidget *scopeDockWidget; bool singleFrameRequested; - AudioScopeData() { singleFrameRequested = false; } + AudioScopeData() { + scope = NULL; + scopeDockWidget = NULL; + singleFrameRequested = false; + } }; public: -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:50
|
Found by Coverity: CID 709303: Uninitialized scalar variable (UNINIT) Declaring variable "profile". 2400 MltVideoProfile profile; At conditional (1): "this->m_activeDocument" taking the false branch. 2401 if (m_activeDocument) profile = m_activeDocument->mltProfile(); Using uninitialized value "profile.colorspace" when calling "MltVideoProfile::MltVideoProfile(MltVideoProfile const &)". [hide details] Using uninitialized value "profile.display_aspect_den" when calling "MltVideoProfile::MltVideoProfile(MltVideoProfile const &)". [show details] Using uninitialized value "profile.display_aspect_num" when calling "MltVideoProfile::MltVideoProfile(MltVideoProfile const &)". [show details] Using uninitialized value "profile.frame_rate_den" when calling "MltVideoProfile::MltVideoProfile(MltVideoProfile const &)". [show details] Using uninitialized value "profile.frame_rate_num" when calling "MltVideoProfile::MltVideoProfile(MltVideoProfile const &)". [show details] Using uninitialized value "profile.height" when calling "MltVideoProfile::MltVideoProfile(MltVideoProfile const &)". [show details] Using uninitialized value "profile.progressive" when calling "MltVideoProfile::MltVideoProfile(MltVideoProfile const &)". [show details] Using uninitialized value "profile.sample_aspect_den" when calling "MltVideoProfile::MltVideoProfile(MltVideoProfile const &)". [show details] Using uninitialized value "profile.sample_aspect_num" when calling "MltVideoProfile::MltVideoProfile(MltVideoProfile const &)". [show details] Using uninitialized value "profile.width" when calling "MltVideoProfile::MltVideoProfile(MltVideoProfile const &)". [show details] CID 709304: Uninitialized scalar variable (UNINIT) Declaring variable "result". 242 MltVideoProfile result; ... --- src/definitions.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/definitions.h b/src/definitions.h index fa22620..1e03945 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -108,7 +108,8 @@ struct TransitionInfo { bool forceTrack; }; -struct MltVideoProfile { +class MltVideoProfile { +public: QString path; QString description; int frame_rate_num; @@ -121,6 +122,17 @@ struct MltVideoProfile { int display_aspect_num; int display_aspect_den; int colorspace; + MltVideoProfile() : + frame_rate_num(0), + frame_rate_den(0), + width(0), + height(0), + progressive(0), + sample_aspect_num(0), + sample_aspect_den(0), + display_aspect_num(0), + display_aspect_den(0), + colorspace(0) {}; bool operator==(const MltVideoProfile& point) const { if (!description.isEmpty() && point.description == description) return true; -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-07-22 18:28:50
|
Hope it's the correct default. Found by Coverity: 42 /** @brief Build an abstract MLT Renderer 43 * @param name A unique identifier for this renderer 44 * @param winid The parent widget identifier (required for SDL display). Set to 0 for OpenGL rendering 45 * @param profile The MLT profile used for the renderer (default one will be used if empty). */ CID 709307: Uninitialized scalar field (UNINIT_CTOR) Non-static class member ""analyseAudio"" is not initialized in this constructor nor in any functions that it calls. 46 AbstractRender(Kdenlive::MONITORID name, QWidget *parent = 0):QObject(parent), sendFrameForAnalysis(false), m_name(name) {}; 47 48 /** @brief Destroy the MLT Renderer. */ 49 virtual ~AbstractRender() {}; 50 51 /** @brief This property is used to decide if the renderer should convert it's frames to QImage for use in other Kdenlive widgets. */ 52 bool sendFrameForAnalysis; 53 54 /** @brief This property is used to decide if the renderer should send audio data for monitoring. */ Class member declaration for ""analyseAudio"". 55 bool analyseAudio; --- src/abstractmonitor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abstractmonitor.h b/src/abstractmonitor.h index 5eea227..0a82128 100644 --- a/src/abstractmonitor.h +++ b/src/abstractmonitor.h @@ -43,7 +43,7 @@ Q_OBJECT public: * @param name A unique identifier for this renderer * @param winid The parent widget identifier (required for SDL display). Set to 0 for OpenGL rendering * @param profile The MLT profile used for the renderer (default one will be used if empty). */ - explicit AbstractRender(Kdenlive::MONITORID name, QWidget *parent = 0):QObject(parent), sendFrameForAnalysis(false), m_name(name) {}; + explicit AbstractRender(Kdenlive::MONITORID name, QWidget *parent = 0):QObject(parent), sendFrameForAnalysis(false), analyseAudio(false), m_name(name) {}; /** @brief Destroy the MLT Renderer. */ virtual ~AbstractRender() {}; -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-08-10 12:17:32
|
Here's another set of fixes for Coverity's findings. I'm not sure all of them do the right thing on error paths so please have a look. Tested locally with a few projects and nothing seems to break. The patches are also available in coverity branch of git tree: https://github.com/mcfrisk/kdenlive.git Mikko Rapeli (16): histogramgenerator.cpp: check for division by zero effectstackview2.cpp: check for null pointer effectstackview2.cpp: check for null audioCorrelationInfo.cpp: check for division by zero audioEnvelope.cpp: check for division by zero meltjob.cpp: initialize addClipToProject dvdwizardvob.cpp: check return value kthumb.cpp: check for division by zero kis_cubic_curve.cpp: initialize variables markerdialog.cpp: add break to switch case projectlist.cpp: check for null before referencing projectlistview.cpp: check for null pointer projectsettings.cpp: return if open() fails renderer.cpp: check for null pointers titledocument.cpp: check return value from open() thumbnailer/westleypreview.cpp: check for division by zero src/colorcorrection/histogramgenerator.cpp | 5 ++++- src/dvdwizardvob.cpp | 5 ++++- src/effectstack/effectstackview2.cpp | 7 ++++--- src/kis_cubic_curve.cpp | 5 +++-- src/kthumb.cpp | 8 ++++++-- src/lib/audio/audioCorrelationInfo.cpp | 3 +++ src/lib/audio/audioEnvelope.cpp | 4 ++++ src/markerdialog.cpp | 1 + src/projectlist.cpp | 8 ++++---- src/projectlistview.cpp | 2 +- src/projectsettings.cpp | 3 ++- src/projecttree/meltjob.cpp | 3 ++- src/renderer.cpp | 18 ++++++++++++++---- src/titledocument.cpp | 3 ++- thumbnailer/westleypreview.cpp | 1 + 15 files changed, 55 insertions(+), 21 deletions(-) -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-08-10 12:17:35
|
Fixes Coverity CID 709275: Unchecked return value (CHECKED_RETURN) Calling function "QDomDocument::setContent(QIODevice *, QString *, int *, int *)" without checking return value (as is done elsewhere 6 out of 7 times). No check of the return value of "doc.setContent(&file, NULL, NULL, NULL)". 134 doc.setContent(&file); --- src/dvdwizardvob.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dvdwizardvob.cpp b/src/dvdwizardvob.cpp index ebc4b84..1caae7f 100644 --- a/src/dvdwizardvob.cpp +++ b/src/dvdwizardvob.cpp @@ -131,7 +131,10 @@ void DvdWizardVob::slotAddVobFile(KUrl url, const QString &chapters) QFile file(url.path() + ".dvdchapter"); if (file.open(QIODevice::ReadOnly)) { QDomDocument doc; - doc.setContent(&file); + if (doc.setContent(&file) == false) { + file.close(); + return; + } file.close(); QDomNodeList chapters = doc.elementsByTagName("chapter"); QStringList chaptersList; -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-08-10 12:17:37
|
Fixes Coverity CID 709290: Dereference after null check (FORWARD_NULL) Comparing "this->m_clipref" to null implies that "this->m_clipref" might be null. 717 else if (m_clipref) { ... Passing null variable "this->m_clipref" to function "AbstractClipItem::info() const", which dereferences it. [show details] 733 info = m_clipref->info(); --- src/effectstack/effectstackview2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/effectstack/effectstackview2.cpp b/src/effectstack/effectstackview2.cpp index 98591ba..c345272 100644 --- a/src/effectstack/effectstackview2.cpp +++ b/src/effectstack/effectstackview2.cpp @@ -729,7 +729,7 @@ void EffectStackView2::slotCreateRegion(int ix, KUrl url) info.startPos = GenTime(-1); info.track = 0; } - else { + else if (m_clipref) { info = m_clipref->info(); } CollapsibleEffect *current = getEffectByIndex(ix); @@ -744,7 +744,7 @@ void EffectStackView2::slotCreateRegion(int ix, KUrl url) if (m_effectMetaInfo.trackMode) { isSelected = currentEffect->effectIndex() == 1; } - else { + else if (m_clipref) { isSelected = currentEffect->effectIndex() == m_clipref->selectedEffectIndex(); } if (isSelected) currentEffect->setActive(true); -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-08-10 12:17:37
|
Fixes Coverity CID 709289: Explicit null dereferenced (FORWARD_NULL) Assigning: "effectToMove" = 0. 790 CollapsibleEffect *effectToMove = NULL; ... Passing null variable "effectToMove" to function "CollapsibleGroup::addGroupEffect(CollapsibleEffect *)", which dereferences it. [show details] 805 group->addGroupEffect(effectToMove); --- src/effectstack/effectstackview2.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/effectstack/effectstackview2.cpp b/src/effectstack/effectstackview2.cpp index c345272..740518c 100644 --- a/src/effectstack/effectstackview2.cpp +++ b/src/effectstack/effectstackview2.cpp @@ -802,7 +802,8 @@ void EffectStackView2::slotCreateGroup(int ix) connectGroup(group); l->insertWidget(groupPos, group); group->installEventFilter( this ); - group->addGroupEffect(effectToMove); + if (effectToMove) + group->addGroupEffect(effectToMove); } void EffectStackView2::connectGroup(CollapsibleGroup *group) -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-08-10 12:17:36
|
Fixes Coverity CID 709284: Division or modulo by zero (DIVIDE_BY_ZERO) Division by expression "byteCount >> 7" which may be zero has undefined behavior 87 const float scaling = (float)partH/(byteCount >> 7); --- src/colorcorrection/histogramgenerator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/colorcorrection/histogramgenerator.cpp b/src/colorcorrection/histogramgenerator.cpp index 456aad6..2681c50 100644 --- a/src/colorcorrection/histogramgenerator.cpp +++ b/src/colorcorrection/histogramgenerator.cpp @@ -84,7 +84,10 @@ QImage HistogramGenerator::calculateHistogram(const QSize ¶deSize, const QIm const int d = 20; // Distance for text const int partH = (wh-nParts*d)/nParts; - const float scaling = (float)partH/(byteCount >> 7); + float scaling = 0; + int div = byteCount >> 7; + if ( div > 0 ) + scaling = (float)partH/(byteCount >> 7); const int dist = 40; int wy = 0; // Drawing position -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-08-10 12:17:36
|
Fixes Coverity CID 709294: Missing break in switch (MISSING_BREAK) This case (value 9) is not terminated by a 'break' statement. 70 case PLAYLIST: 71 connect(this, SIGNAL(updateThumb()), m_previewTimer, SLOT(start())); The above case falls through to this one. 72 case IMAGE: 73 case TEXT: 74 p = QPixmap::fromImage(KThumb::getFrame(m_producer, m_in->getValue(), swidth, width, 100)); 75 break; --- src/markerdialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/markerdialog.cpp b/src/markerdialog.cpp index a3935e5..4c07961 100644 --- a/src/markerdialog.cpp +++ b/src/markerdialog.cpp @@ -69,6 +69,7 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons case SLIDESHOW: case PLAYLIST: connect(this, SIGNAL(updateThumb()), m_previewTimer, SLOT(start())); + break; case IMAGE: case TEXT: p = QPixmap::fromImage(KThumb::getFrame(m_producer, m_in->getValue(), swidth, width, 100)); -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-08-10 12:17:37
|
CID 709285: Division or modulo by zero (DIVIDE_BY_ZERO) Division by expression "STEPS" which may be zero has undefined behavior 250 avg=avg/STEPS; --- src/kthumb.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/kthumb.cpp b/src/kthumb.cpp index c5e1691..428d437 100644 --- a/src/kthumb.cpp +++ b/src/kthumb.cpp @@ -247,7 +247,8 @@ uint KThumb::imageVariance(QImage image ) avg+=pivot[i]; #endif } - avg=avg/STEPS; + if (STEPS) + avg=avg/STEPS; // Second Step: calculate delta (average?) for (uint i=0; i<STEPS; i++) { @@ -258,7 +259,10 @@ uint KThumb::imageVariance(QImage image ) #endif delta+=curdelta; } - return delta/STEPS; + if (STEPS) + return delta/STEPS; + else + return 0; } /* -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-08-10 12:17:38
|
Fixes Coverity CID 709281: Unchecked return value (CHECKED_RETURN) Calling function "QFile::open(QFlags<QIODevice::OpenModeFlag>)" without checking return value (as is done elsewhere 45 out of 47 times). No check of the return value of "xmlf.open(QIODevice::OpenMode(_ZN9QIODevice9WriteOnlyE))". 552 xmlf.open(QIODevice::WriteOnly); --- src/projectsettings.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/projectsettings.cpp b/src/projectsettings.cpp index ba8aebf..9289e18 100644 --- a/src/projectsettings.cpp +++ b/src/projectsettings.cpp @@ -549,7 +549,8 @@ void ProjectSettings::slotExportToText() return; } QFile xmlf(tmpfile.fileName()); - xmlf.open(QIODevice::WriteOnly); + if (!xmlf.open(QIODevice::WriteOnly)) + return; xmlf.write(data.toUtf8()); if (xmlf.error() != QFile::NoError) { xmlf.close(); -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-08-10 12:17:37
|
Fixes Coverity CID 709286: Division or modulo by zero (DIVIDE_BY_ZERO) Assigning: "maxVal" = "this->max()". On this path, function call "this->max()" has return value of 0 78 int64_t maxVal = max(); ... Division by expression "maxVal" which may be zero has undefined behavior 86 val = m_correlationVector[x]/double(maxVal)*img.height(); --- src/lib/audio/audioCorrelationInfo.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/audio/audioCorrelationInfo.cpp b/src/lib/audio/audioCorrelationInfo.cpp index ea9e90c..db438bd 100644 --- a/src/lib/audio/audioCorrelationInfo.cpp +++ b/src/lib/audio/audioCorrelationInfo.cpp @@ -80,6 +80,9 @@ QImage AudioCorrelationInfo::toImage(int height) const QImage img(width, height, QImage::Format_ARGB32); img.fill(qRgb(255,255,255)); + if (maxVal == 0) + return img; + int val; for (int x = 0; x < width; x++) { -- 1.7.10.4 |
From: Mikko R. <mik...@ik...> - 2012-08-10 12:17:38
|
Fixes Coverity CID 709288: Division or modulo by zero (DIVIDE_BY_ZERO) Division by expression "STEPS" which may be zero has undefined behavior 139 avg=avg/STEPS; ... 150 return delta / STEPS; --- thumbnailer/westleypreview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/thumbnailer/westleypreview.cpp b/thumbnailer/westleypreview.cpp index 8512b60..9113278 100644 --- a/thumbnailer/westleypreview.cpp +++ b/thumbnailer/westleypreview.cpp @@ -123,6 +123,7 @@ uint MltPreview::imageVariance(QImage image) uint delta = 0; uint avg = 0; uint bytes = image.numBytes(); + if (bytes == 0) return 0; uint STEPS = bytes / 2; QVarLengthArray<uchar> pivot(STEPS); kDebug(DBG_AREA) << "Using " << STEPS << " steps\n"; -- 1.7.10.4 |