summaryrefslogtreecommitdiff
authorerik <erik>2007-02-08 01:45:16 (UTC)
committer erik <erik>2007-02-08 01:45:16 (UTC)
commit2e497f7cae45184184e2416114887095735958f5 (patch) (side-by-side diff)
treea6b399d9bce5854dc7ad6c985b48965cf20680b0
parent853b61f97e718359bef95147ab3c7beb0705acda (diff)
downloadopie-2e497f7cae45184184e2416114887095735958f5.zip
opie-2e497f7cae45184184e2416114887095735958f5.tar.gz
opie-2e497f7cae45184184e2416114887095735958f5.tar.bz2
Each file in this commit has a problem where it is possible to dereference
a pointer without that pointer being valid. This commit fixes each instance of that.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/modplug/sndfile.cpp5
-rw-r--r--core/multimedia/opieplayer/vorbis/tremor/block.c2
-rw-r--r--core/multimedia/opieplayer/vorbis/tremor/info.c2
-rw-r--r--noncore/apps/opie-write/qrichtext.cpp41
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp3
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp6
6 files changed, 46 insertions, 13 deletions
diff --git a/core/multimedia/opieplayer/modplug/sndfile.cpp b/core/multimedia/opieplayer/modplug/sndfile.cpp
index 1d0d610..799555c 100644
--- a/core/multimedia/opieplayer/modplug/sndfile.cpp
+++ b/core/multimedia/opieplayer/modplug/sndfile.cpp
@@ -1741,3 +1741,6 @@ BOOL CSoundFile::SetPatternName(UINT nPat, LPCSTR lpszName)
if (nPat >= MAX_PATTERNS) return FALSE;
- if (lpszName) lstrcpyn(szName, lpszName, MAX_PATTERNNAME);
+ if (lpszName)
+ lstrcpyn(szName, lpszName, MAX_PATTERNNAME);
+ else
+ return FALSE;
szName[MAX_PATTERNNAME-1] = 0;
diff --git a/core/multimedia/opieplayer/vorbis/tremor/block.c b/core/multimedia/opieplayer/vorbis/tremor/block.c
index 8949253..7b5531b 100644
--- a/core/multimedia/opieplayer/vorbis/tremor/block.c
+++ b/core/multimedia/opieplayer/vorbis/tremor/block.c
@@ -228,4 +228,6 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){
if(v->pcm){
+ if (vi) {
for(i=0;i<vi->channels;i++)
if(v->pcm[i])_ogg_free(v->pcm[i]);
+ }
_ogg_free(v->pcm);
diff --git a/core/multimedia/opieplayer/vorbis/tremor/info.c b/core/multimedia/opieplayer/vorbis/tremor/info.c
index 941695e..3499ae4 100644
--- a/core/multimedia/opieplayer/vorbis/tremor/info.c
+++ b/core/multimedia/opieplayer/vorbis/tremor/info.c
@@ -99,5 +99,5 @@ void vorbis_comment_clear(vorbis_comment *vc){
if(vc->vendor)_ogg_free(vc->vendor);
- }
memset(vc,0,sizeof(*vc));
}
+}
diff --git a/noncore/apps/opie-write/qrichtext.cpp b/noncore/apps/opie-write/qrichtext.cpp
index f040f1e..768da44 100644
--- a/noncore/apps/opie-write/qrichtext.cpp
+++ b/noncore/apps/opie-write/qrichtext.cpp
@@ -191,5 +191,8 @@ QTextCursor *QTextDeleteCommand::execute( QTextCursor *c )
QTextParagraph *s = doc ? doc->paragAt( id ) : parag;
- if ( !s ) {
+ if ( !s && doc ) {
owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl;
return 0;
+ } else if ( !doc ) {
+ owarn << "No valid doc" << oendl;
+ return 0;
}
@@ -219,5 +222,8 @@ QTextCursor *QTextDeleteCommand::unexecute( QTextCursor *c )
QTextParagraph *s = doc ? doc->paragAt( id ) : parag;
- if ( !s ) {
+ if ( !s && doc ) {
owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl;
return 0;
+ } else if ( !doc ) {
+ owarn << "No valid doc" << oendl;
+ return 0;
}
@@ -235,2 +241,5 @@ QTextCursor *QTextDeleteCommand::unexecute( QTextCursor *c )
c->gotoNextLetter();
+ } else {
+ owarn << "No valid cursor" << oendl;
+ return 0;
}
@@ -1394,6 +1403,17 @@ struct Q_EXPORT QTextDocumentTag {
-#define NEWPAR do{ if ( !hasNewPar) { \
+#define NEWPAR do { \
+ if ( !hasNewPar) { \
+ if ( !curpar ) { \
+ owarn << "no current paragraph" << oendl; \
+ return; \
+ } \
if ( !textEditMode && curpar && curpar->length()>1 && curpar->at( curpar->length()-2)->c == QChar_linesep ) \
curpar->remove( curpar->length()-2, 1 ); \
- curpar = createParagraph( this, curpar, curpar->next() ); styles.append( vec ); vec = 0;} \
+ curpar = createParagraph( this, curpar, curpar->next() ); styles.append( vec ); \
+ if ( !curpar ) { \
+ owarn << "failed in creating a new paragraph" << oendl; \
+ return; \
+ } \
+ vec = 0; \
+ } \
hasNewPar = TRUE; \
@@ -1405,3 +1425,4 @@ struct Q_EXPORT QTextDocumentTag {
space = TRUE; \
- delete vec; vec = new QPtrVector<QStyleSheetItem>( (uint)tags.count() + 1); \
+ delete vec; \
+ vec = new QPtrVector<QStyleSheetItem>( (uint)tags.count() + 1); \
int i = 0; \
@@ -1412,3 +1433,2 @@ struct Q_EXPORT QTextDocumentTag {
-
void QTextDocument::setRichText( const QString &text, const QString &context )
@@ -1897,4 +1917,7 @@ void QTextDocument::setRichTextMarginsInternal( QPtrList< QPtrVector<QStyleSheet
int i, mar;
- QStyleSheetItem* mainStyle = curStyle->size() ? (*curStyle)[curStyle->size()-1] : 0;
- if ( mainStyle && mainStyle->displayMode() == QStyleSheetItem::DisplayListItem )
+ QStyleSheetItem* mainStyle = (*curStyle)[curStyle->size()-1];
+ if ( !mainStyle )
+ return;
+
+ if ( mainStyle->displayMode() == QStyleSheetItem::DisplayListItem )
stylesPar->setListItem( TRUE );
@@ -5343,3 +5366,3 @@ int QTextFormatterBreakWords::format( QTextDocument *doc, QTextParagraph *parag,
// ### next line should not be needed
- if ( painter )
+ if ( c && painter )
c->format()->setPainter( painter );
diff --git a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp
index 9069c09..3fd877f 100644
--- a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp
@@ -297,2 +297,5 @@ UUIDVector OTSDPAttribute::getAllUUIDs() {
+ if (!subAttributes)
+ return 0;
+
int os;
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
index d014378..78a18f7 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
@@ -438,3 +438,5 @@ void OIpkgConfigDlg::initData()
// Get Ipkg execution options
- int options = m_ipkg->ipkgExecOptions();
+ int options = 0;
+ if ( m_ipkg )
+ options = m_ipkg->ipkgExecOptions();
if ( options & FORCE_DEPENDS )
@@ -452,3 +454,3 @@ void OIpkgConfigDlg::initData()
- m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() );
+ m_optVerboseIpkg->setCurrentItem( ( m_ipkg ? m_ipkg->ipkgExecVerbosity() : 0 ) );
}