Git commit cf01ff3159dbddb97e0e67246dee16441a64984a by Leslie Zhai. Committed on 14/11/2016 at 08:06. Pushed by lesliezhai into branch 'cdrskin'. Fix issues detected by clang-analyzer M +2 -2 INSTALL.txt M +2 -0 libk3b/projects/audiocd/k3baudiodoc.cpp M +4 -0 libk3b/projects/movixcd/k3bmovixdocpreparer.cpp M +3 -1 libk3b/projects/movixcd/k3bmovixprogram.cpp M +4 -2 libk3b/projects/videocd/mpeginfo/k3bmpeginfo.cpp M +3 -5 libk3bdevice/k3bdevice_mmc.cpp M +3 -1 plugins/project/audiometainforenamer/k3baudiometainforenamer= plugin.cpp M +1 -0 src/k3b.cpp M +3 -0 src/k3bmetaitemmodel.cpp M +11 -9 src/misc/k3bmediacopydialog.cpp M +1 -1 src/projects/k3baudioprojectmodel.cpp M +7 -6 src/projects/k3bdataurladdingdialog.cpp M +4 -2 src/rip/videodvd/k3bvideodvdrippingpreview.cpp http://commits.kde.org/k3b/cf01ff3159dbddb97e0e67246dee16441a64984a diff --git a/INSTALL.txt b/INSTALL.txt index cd2f589..880b02b 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -36,7 +36,7 @@ After that it's all the same: = For debug: = - cmake .. -DCMAKE_INSTALL_PREFIX=3D/usr \ + scan-build -k -v -V cmake .. -DCMAKE_INSTALL_PREFIX=3D/usr \ -DKDE_INSTALL_LIBDIR=3Dlib \ -DKDE_INSTALL_LIBEXECDIR=3Dlib \ -DKDE_INSTALL_USE_QT_SYS_PATHS=3DON \ @@ -47,7 +47,7 @@ For debug: If the cmake run was successful you are presented with a list of configure= results that shows which optional features are enabled. Now just compile K3b: = - make + scan-build -k -v -V make = Now you are ready to install: = diff --git a/libk3b/projects/audiocd/k3baudiodoc.cpp b/libk3b/projects/audi= ocd/k3baudiodoc.cpp index c9227cd..362eb82 100644 --- a/libk3b/projects/audiocd/k3baudiodoc.cpp +++ b/libk3b/projects/audiocd/k3baudiodoc.cpp @@ -721,11 +721,13 @@ bool K3b::AudioDoc::loadDocumentData( QDomElement* ro= ot ) } else { qDebug() << "(K3b::AudioDoc) invalid c= dtrack source."; + delete track; return false; } } else { qDebug() << "(K3b::AudioDoc) unknown sourc= e type: " << sourceElem.nodeName(); + delete track; return false; } } diff --git a/libk3b/projects/movixcd/k3bmovixdocpreparer.cpp b/libk3b/proje= cts/movixcd/k3bmovixdocpreparer.cpp index c60a9d5..9c49ccd 100644 --- a/libk3b/projects/movixcd/k3bmovixdocpreparer.cpp +++ b/libk3b/projects/movixcd/k3bmovixdocpreparer.cpp @@ -257,6 +257,8 @@ bool K3b::MovixDocPreparer::addMovixFiles() // first of all we create the directories d->isolinuxDir =3D new K3b::DirItem( "isolinux" ); d->movixDir =3D new K3b::DirItem( "movix" ); + if (d->doc =3D=3D Q_NULLPTR) + return false; d->doc->root()->addDataItem( d->isolinuxDir ); d->doc->root()->addDataItem( d->movixDir ); K3b::DirItem* kernelDir =3D d->doc->addEmptyDir( "kernel", d->isolinux= Dir ); @@ -362,6 +364,8 @@ bool K3b::MovixDocPreparer::addMovixFilesNew() // 3. add movixrc and movix.list files // 4. set weights for isolinux files = + if (d->doc =3D=3D Q_NULLPTR) + return false; // FIXME: use the settings from the doc const QStringList files =3D d->eMovixBin->files( d->doc->keyboardLayou= t(), d->doc->subtitleFontset(), diff --git a/libk3b/projects/movixcd/k3bmovixprogram.cpp b/libk3b/projects/= movixcd/k3bmovixprogram.cpp index 6afb44e..0d767d3 100644 --- a/libk3b/projects/movixcd/k3bmovixprogram.cpp +++ b/libk3b/projects/movixcd/k3bmovixprogram.cpp @@ -70,7 +70,7 @@ bool K3b::MovixProgram::scan( const QString& p ) return false; } = - if( bin->version() >=3D K3b::Version( 0, 9, 0 ) ) + if( bin && bin->version() >=3D K3b::Version( 0, 9, 0 ) ) return scanNewEMovix( bin, path ); else return scanOldEMovix( bin, path ); @@ -106,6 +106,8 @@ bool K3b::MovixProgram::scanOldEMovix( K3b::MovixBin* b= in, const QString& path ) // // first check if all necessary directories are present // + if (bin =3D=3D Q_NULLPTR) + return false; QDir dir( bin->movixDataDir() ); QStringList subdirs =3D dir.entryList( QDir::Dirs ); if( !subdirs.contains( "boot-messages" ) ) { diff --git a/libk3b/projects/videocd/mpeginfo/k3bmpeginfo.cpp b/libk3b/proj= ects/videocd/mpeginfo/k3bmpeginfo.cpp index ea24c95..a1ae0db 100644 --- a/libk3b/projects/videocd/mpeginfo/k3bmpeginfo.cpp +++ b/libk3b/projects/videocd/mpeginfo/k3bmpeginfo.cpp @@ -257,7 +257,9 @@ llong K3b::MpegInfo::MpegParsePacket ( llong offset ) offset +=3D 4; size =3D GetSize( offset ); offset +=3D 2; - // qDebug() << QString( "offset =3D %1, size =3D %2" ).arg( offset= ).arg( size ); +#ifdef K3B_DEBUG + qDebug() << QString( "offset =3D %1, size =3D %2" ).arg( offset ).= arg( size ); +#endif = switch ( mark ) { case MPEG_SYSTEM_HEADER_CODE: @@ -760,7 +762,7 @@ void K3b::MpegInfo::ParseVideo ( llong offset, byte mar= ker ) = mpeg_info->video[ v_idx ].bitrate =3D 400 * brate; = - byte mark; + byte mark =3D -1; while ( true ) { offset =3D FindNextMarker( offset, &mark ); if ( mark =3D=3D MPEG_GOP_CODE ) diff --git a/libk3bdevice/k3bdevice_mmc.cpp b/libk3bdevice/k3bdevice_mmc.cpp index 4493edb..bbd3331 100644 --- a/libk3bdevice/k3bdevice_mmc.cpp +++ b/libk3bdevice/k3bdevice_mmc.cpp @@ -202,9 +202,7 @@ bool K3b::Device::Device::getPerformance( UByteArray& d= ata, // return types. "Defect Status Data" for example might return = way more data. // FIXME: Since we only use getPerformance for writing speeds and with= out a proper length // those do not make sense it is better to fail here anyway. - if( (dataLen-8) % descLen || - dataLen <=3D 8 || - dataLen > 2048 ) { + if( descLen =3D=3D 0 || (dataLen-8) % descLen || dataLen <=3D 8 || dat= aLen > 2048 ) { qDebug() << "(K3b::Device::Device) " << blockDeviceName() << ": GET PERFORMANCE reports bogus dataLen: " << dataLen= << endl; return false; @@ -586,7 +584,7 @@ bool K3b::Device::Device::readTocPmaAtip( UByteArray& d= ata, int format, bool tim // with these buggy drives. // We cannot use this as default since many firmwares fail with a too = high data length. // - if( (dataLen-4) % descLen || dataLen < 4+descLen ) { + if( descLen !=3D 0 && ((dataLen-4) % descLen || dataLen < 4+descLen) )= { qDebug() << "(K3b::Device::Device) " << blockDeviceName() << ": RE= AD TOC/PMA/ATIP invalid length returned: " << dataLen; dataLen =3D 0xFFFF; } @@ -605,7 +603,7 @@ bool K3b::Device::Device::readTocPmaAtip( UByteArray& d= ata, int format, bool tim cmd[8] =3D data.size(); if( cmd.transport( TR_DIR_READ, data.data(), data.size() ) =3D=3D 0 ) { dataLen =3D qMin( dataLen, from2Byte( data.data() ) + 2u ); - if( (dataLen-4) % descLen || dataLen < 4+descLen ) { + if( descLen =3D=3D 0 || (dataLen-4) % descLen || dataLen < 4+descL= en ) { // useless length data.clear(); return false; diff --git a/plugins/project/audiometainforenamer/k3baudiometainforenamerpl= ugin.cpp b/plugins/project/audiometainforenamer/k3baudiometainforenamerplug= in.cpp index 1d67a06..67567c7 100644 --- a/plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.cpp +++ b/plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.cpp @@ -46,6 +46,7 @@ #include #include #include +#include = #include #include @@ -149,7 +150,8 @@ K3bAudioMetainfoRenamerPluginWidget::K3bAudioMetainfoRe= namerPluginWidget( K3b::D "%n (Track number), and <= em>%t (Title) " "are supported.") ); = - TagLib::FileRef::addFileTypeResolver( new K3bMimeTypeResolver() ); + QSharedPointer typePtr =3D QSharedPointer(new K3bMimeTypeResolver); + TagLib::FileRef::addFileTypeResolver(typePtr.data()); } = = diff --git a/src/k3b.cpp b/src/k3b.cpp index df34794..5dc6045 100644 --- a/src/k3b.cpp +++ b/src/k3b.cpp @@ -288,6 +288,7 @@ void K3b::MainWindow::initActions() // need to have all actions in the mainwindow's actioncollection anywa= y (or am I just to stupid to // see the correct solution?) = + // clang-analyzer wrongly treat KF5's KStandardAction::open as Unix AP= I Improper use of 'open' QAction* actionFileOpen =3D KStandardAction::open( this, SLOT(slotFile= Open()), actionCollection() ); actionFileOpen->setToolTip( i18n( "Opens an existing project" ) ); actionFileOpen->setStatusTip( actionFileOpen->toolTip() ); diff --git a/src/k3bmetaitemmodel.cpp b/src/k3bmetaitemmodel.cpp index 1cf0259..f3acaeb 100644 --- a/src/k3bmetaitemmodel.cpp +++ b/src/k3bmetaitemmodel.cpp @@ -180,6 +180,9 @@ namespace { = // all the node mapping is done on the first col, so make sure we = use // an index on the first col + // = + // A valid index belongs to a model, and has non-negative row and = column numbers + // so index.model() is NOT nullptr if index.isValid() QModelIndex firstColIndex =3D index.model()->index(index.row(), 0,= index.parent()); Node* node =3D findNodeForOriginalIndex( firstColIndex ); if ( !node ) { diff --git a/src/misc/k3bmediacopydialog.cpp b/src/misc/k3bmediacopydialog.= cpp index 9281ca6..0269b67 100644 --- a/src/misc/k3bmediacopydialog.cpp +++ b/src/misc/k3bmediacopydialog.cpp @@ -300,6 +300,7 @@ void K3b::MediaCopyDialog::slotStartClicked() i18n("File Exists"), KStandardGuiItem::over= write() ) !=3D KMessageBox::Continue ) + delete dlg; return; } = @@ -484,16 +485,17 @@ void K3b::MediaCopyDialog::toggleAll() } else if ( sourceMedium.diskInfo().mediaType() & K3b::Device::M= EDIA_DVD_ALL ) { // only auto for DVD+R(W) - if( burnDev->writeCapabilities() & (K3b::Device::MEDIA_DVD= _R|K3b::Device::MEDIA_DVD_RW) ) { - modes |=3D K3b::WritingModeSao|K3b::WritingModeRestric= tedOverwrite; - if( burnDev->featureCurrent( K3b::Device::FEATURE_INCR= EMENTAL_STREAMING_WRITABLE ) !=3D 0 ) - modes |=3D K3b::WritingModeIncrementalSequential; + if (burnDev) { + if( burnDev->writeCapabilities() & (K3b::Device::MEDIA= _DVD_R|K3b::Device::MEDIA_DVD_RW) ) { + modes |=3D K3b::WritingModeSao|K3b::WritingModeRes= trictedOverwrite; + if( burnDev->featureCurrent( K3b::Device::FEATURE_= INCREMENTAL_STREAMING_WRITABLE ) !=3D 0 ) + modes |=3D K3b::WritingModeIncrementalSequenti= al; + } + + // TODO: once we have layer jump support: this is wher= e it goes + //if ( burnDev->supportsWritingMode( K3b::Device::WRIT= ING_MODE_LAYER_JUMP ) ) + // modes |=3D K3b::Device::WRITING_MODE_LAYER_JUMP; } - - // TODO: once we have layer jump support: this is where it= goes -// if ( burnDev->supportsWritingMode( K3b::Device::WRITING_M= ODE_LAYER_JUMP ) ) { -// modes |=3D K3b::Device::WRITING_MODE_LAYER_JUMP; -// } } else if ( sourceMedium.diskInfo().mediaType() & K3b::Device::M= EDIA_BD_ALL ) { // no modes, only auto diff --git a/src/projects/k3baudioprojectmodel.cpp b/src/projects/k3baudiop= rojectmodel.cpp index a9bc3c3..cf4f7e1 100644 --- a/src/projects/k3baudioprojectmodel.cpp +++ b/src/projects/k3baudioprojectmodel.cpp @@ -632,7 +632,7 @@ bool K3b::AudioProjectModel::dropMimeData( const QMimeD= ata* data, Qt::DropAction = // special case: the source we remove from the track is th= e last and the track // will be deleted. - if( !copyItems && dropTrackAfter =3D=3D source->track() &&= dropTrackAfter->numberSources() =3D=3D 1 ) + if( !copyItems && dropTrackAfter =3D=3D source->track() &&= dropTrackAfter && dropTrackAfter->numberSources() =3D=3D 1 ) dropTrackAfter =3D dropTrackAfter->prev(); = if( copyItems ) diff --git a/src/projects/k3bdataurladdingdialog.cpp b/src/projects/k3bdata= urladdingdialog.cpp index 4dc70da..28986e9 100644 --- a/src/projects/k3bdataurladdingdialog.cpp +++ b/src/projects/k3bdataurladdingdialog.cpp @@ -50,6 +50,7 @@ #include #include #include +#include = #include = @@ -143,8 +144,8 @@ void K3b::DataUrlAddingDialog::addUrls( const QList& urls, QWidget* parent ) { if( !urls.isEmpty() ) { - K3b::DataUrlAddingDialog* dlg =3D new K3b::DataUrlAddingDialog( ur= ls, dir, parent ); - QMetaObject::invokeMethod( dlg, "slotStartAddUrls", Qt::QueuedConn= ection ); + QSharedPointer dlgPtr =3D QSharedPointer(new DataUrlAddingDialog( urls, dir, parent )); + QMetaObject::invokeMethod( dlgPtr.data(), "slotStartAddUrls", Qt::= QueuedConnection ); } } = @@ -154,8 +155,8 @@ void K3b::DataUrlAddingDialog::moveItems( const QList& items, QWidget* parent ) { if( !items.isEmpty() ) { - DataUrlAddingDialog* dlg =3D new DataUrlAddingDialog( items, dir, = false, parent ); - QMetaObject::invokeMethod( dlg, "slotStartCopyMoveItems", Qt::Queu= edConnection ); + QSharedPointer dlgPtr =3D QSharedPointer(new DataUrlAddingDialog( items, dir, false, parent )); + QMetaObject::invokeMethod( dlgPtr.data(), "slotStartCopyMoveItems"= , Qt::QueuedConnection ); } } = @@ -165,8 +166,8 @@ void K3b::DataUrlAddingDialog::copyItems( const QList& items, QWidget* parent ) { if( !items.isEmpty() ) { - DataUrlAddingDialog* dlg =3D new DataUrlAddingDialog( items, dir, = true, parent ); - QMetaObject::invokeMethod( dlg, "slotStartCopyMoveItems", Qt::Queu= edConnection ); + QSharedPointer dlgPtr =3D QSharedPointer(new DataUrlAddingDialog( items, dir, true, parent )); + QMetaObject::invokeMethod( dlgPtr.data(), "slotStartCopyMoveItems"= , Qt::QueuedConnection ); } } = diff --git a/src/rip/videodvd/k3bvideodvdrippingpreview.cpp b/src/rip/video= dvd/k3bvideodvdrippingpreview.cpp index af20227..0b51452 100644 --- a/src/rip/videodvd/k3bvideodvdrippingpreview.cpp +++ b/src/rip/videodvd/k3bvideodvdrippingpreview.cpp @@ -43,8 +43,10 @@ void K3b::VideoDVDRippingPreview::generatePreview( const= K3b::VideoDVD::VideoDVD { // cleanup first cancel(); - m_process->deleteLater(); - m_process =3D 0; + if (m_process) { + m_process->deleteLater(); + m_process =3D 0; + } m_tempDir.reset(); m_canceled =3D false; =20