summaryrefslogtreecommitdiff
authorerik <erik>2007-02-08 01:45:16 (UTC)
committer erik <erik>2007-02-08 01:45:16 (UTC)
commit2e497f7cae45184184e2416114887095735958f5 (patch) (unidiff)
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) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/modplug/sndfile.cpp5
-rw-r--r--core/multimedia/opieplayer/vorbis/tremor/block.c6
-rw-r--r--core/multimedia/opieplayer/vorbis/tremor/info.c2
-rw-r--r--noncore/apps/opie-write/qrichtext.cpp69
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp3
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp6
6 files changed, 62 insertions, 29 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
@@ -1736,13 +1736,16 @@ void CSoundFile::CheckCPUUsage(UINT nCPU)
1736 1736
1737BOOL CSoundFile::SetPatternName(UINT nPat, LPCSTR lpszName) 1737BOOL CSoundFile::SetPatternName(UINT nPat, LPCSTR lpszName)
1738//--------------------------------------------------------- 1738//---------------------------------------------------------
1739{ 1739{
1740 char szName[MAX_PATTERNNAME] = ""; // changed from CHAR 1740 char szName[MAX_PATTERNNAME] = ""; // changed from CHAR
1741 if (nPat >= MAX_PATTERNS) return FALSE; 1741 if (nPat >= MAX_PATTERNS) return FALSE;
1742 if (lpszName) lstrcpyn(szName, lpszName, MAX_PATTERNNAME); 1742 if (lpszName)
1743 lstrcpyn(szName, lpszName, MAX_PATTERNNAME);
1744 else
1745 return FALSE;
1743 szName[MAX_PATTERNNAME-1] = 0; 1746 szName[MAX_PATTERNNAME-1] = 0;
1744 if (!m_lpszPatternNames) m_nPatternNames = 0; 1747 if (!m_lpszPatternNames) m_nPatternNames = 0;
1745 if (nPat >= m_nPatternNames) 1748 if (nPat >= m_nPatternNames)
1746 { 1749 {
1747 if (!lpszName[0]) return TRUE; 1750 if (!lpszName[0]) return TRUE;
1748 UINT len = (nPat+1)*MAX_PATTERNNAME; 1751 UINT len = (nPat+1)*MAX_PATTERNNAME;
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
@@ -223,14 +223,16 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){
223 if(v){ 223 if(v){
224 vorbis_info *vi=v->vi; 224 vorbis_info *vi=v->vi;
225 codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); 225 codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL);
226 private_state *b=(private_state *)v->backend_state; 226 private_state *b=(private_state *)v->backend_state;
227 227
228 if(v->pcm){ 228 if(v->pcm){
229 for(i=0;i<vi->channels;i++) 229 if (vi) {
230 if(v->pcm[i])_ogg_free(v->pcm[i]); 230 for(i=0;i<vi->channels;i++)
231 if(v->pcm[i])_ogg_free(v->pcm[i]);
232 }
231 _ogg_free(v->pcm); 233 _ogg_free(v->pcm);
232 if(v->pcmret)_ogg_free(v->pcmret); 234 if(v->pcmret)_ogg_free(v->pcmret);
233 } 235 }
234 236
235 /* free mode lookups; these are actually vorbis_look_mapping structs */ 237 /* free mode lookups; these are actually vorbis_look_mapping structs */
236 if(ci){ 238 if(ci){
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
@@ -94,14 +94,14 @@ void vorbis_comment_clear(vorbis_comment *vc){
94 long i; 94 long i;
95 for(i=0;i<vc->comments;i++) 95 for(i=0;i<vc->comments;i++)
96 if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); 96 if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
97 if(vc->user_comments)_ogg_free(vc->user_comments); 97 if(vc->user_comments)_ogg_free(vc->user_comments);
98 if(vc->comment_lengths)_ogg_free(vc->comment_lengths); 98 if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
99 if(vc->vendor)_ogg_free(vc->vendor); 99 if(vc->vendor)_ogg_free(vc->vendor);
100 memset(vc,0,sizeof(*vc));
100 } 101 }
101 memset(vc,0,sizeof(*vc));
102} 102}
103 103
104/* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. 104/* blocksize 0 is guaranteed to be short, 1 is guarantted to be long.
105 They may be equal, but short will never ge greater than long */ 105 They may be equal, but short will never ge greater than long */
106int vorbis_info_blocksize(vorbis_info *vi,int zo){ 106int vorbis_info_blocksize(vorbis_info *vi,int zo){
107 codec_setup_info *ci = (codec_setup_info *)vi->codec_setup; 107 codec_setup_info *ci = (codec_setup_info *)vi->codec_setup;
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
@@ -186,15 +186,18 @@ QTextDeleteCommand::~QTextDeleteCommand()
186 text.resize( 0 ); 186 text.resize( 0 );
187} 187}
188 188
189QTextCursor *QTextDeleteCommand::execute( QTextCursor *c ) 189QTextCursor *QTextDeleteCommand::execute( QTextCursor *c )
190{ 190{
191 QTextParagraph *s = doc ? doc->paragAt( id ) : parag; 191 QTextParagraph *s = doc ? doc->paragAt( id ) : parag;
192 if ( !s ) { 192 if ( !s && doc ) {
193 owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl; 193 owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl;
194 return 0; 194 return 0;
195 } else if ( !doc ) {
196 owarn << "No valid doc" << oendl;
197 return 0;
195 } 198 }
196 199
197 cursor.setParagraph( s ); 200 cursor.setParagraph( s );
198 cursor.setIndex( index ); 201 cursor.setIndex( index );
199 int len = text.size(); 202 int len = text.size();
200 if ( c ) 203 if ( c )
@@ -214,15 +217,18 @@ QTextCursor *QTextDeleteCommand::execute( QTextCursor *c )
214 return c; 217 return c;
215} 218}
216 219
217QTextCursor *QTextDeleteCommand::unexecute( QTextCursor *c ) 220QTextCursor *QTextDeleteCommand::unexecute( QTextCursor *c )
218{ 221{
219 QTextParagraph *s = doc ? doc->paragAt( id ) : parag; 222 QTextParagraph *s = doc ? doc->paragAt( id ) : parag;
220 if ( !s ) { 223 if ( !s && doc ) {
221 owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl; 224 owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl;
222 return 0; 225 return 0;
226 } else if ( !doc ) {
227 owarn << "No valid doc" << oendl;
228 return 0;
223 } 229 }
224 230
225 cursor.setParagraph( s ); 231 cursor.setParagraph( s );
226 cursor.setIndex( index ); 232 cursor.setIndex( index );
227 QString str = QTextString::toString( text ); 233 QString str = QTextString::toString( text );
228 cursor.insert( str, TRUE, &text ); 234 cursor.insert( str, TRUE, &text );
@@ -230,12 +236,15 @@ QTextCursor *QTextDeleteCommand::unexecute( QTextCursor *c )
230 cursor.setIndex( index ); 236 cursor.setIndex( index );
231 if ( c ) { 237 if ( c ) {
232 c->setParagraph( s ); 238 c->setParagraph( s );
233 c->setIndex( index ); 239 c->setIndex( index );
234 for ( int i = 0; i < (int)text.size(); ++i ) 240 for ( int i = 0; i < (int)text.size(); ++i )
235 c->gotoNextLetter(); 241 c->gotoNextLetter();
242 } else {
243 owarn << "No valid cursor" << oendl;
244 return 0;
236 } 245 }
237 246
238 if ( !styleInformation.isEmpty() ) { 247 if ( !styleInformation.isEmpty() ) {
239 QDataStream styleStream( styleInformation, IO_ReadOnly ); 248 QDataStream styleStream( styleInformation, IO_ReadOnly );
240 int num; 249 int num;
241 styleStream >> num; 250 styleStream >> num;
@@ -1389,30 +1398,41 @@ struct Q_EXPORT QTextDocumentTag {
1389#if defined(Q_FULL_TEMPLATE_INSTANTIATION) 1398#if defined(Q_FULL_TEMPLATE_INSTANTIATION)
1390 bool operator==( const QTextDocumentTag& ) const { return FALSE; } 1399 bool operator==( const QTextDocumentTag& ) const { return FALSE; }
1391#endif 1400#endif
1392}; 1401};
1393 1402
1394 1403
1395#define NEWPAR do{ if ( !hasNewPar) { \ 1404#define NEWPAR do { \
1396 if ( !textEditMode && curpar && curpar->length()>1 && curpar->at( curpar->length()-2)->c == QChar_linesep ) \ 1405 if ( !hasNewPar) { \
1397 curpar->remove( curpar->length()-2, 1 ); \ 1406 if ( !curpar ) { \
1398 curpar = createParagraph( this, curpar, curpar->next() ); styles.append( vec ); vec = 0;} \ 1407 owarn << "no current paragraph" << oendl; \
1399 hasNewPar = TRUE; \ 1408 return; \
1400 curpar->rtext = TRUE; \ 1409 } \
1401 curpar->align = curtag.alignment; \ 1410 if ( !textEditMode && curpar && curpar->length()>1 && curpar->at( curpar->length()-2)->c == QChar_linesep ) \
1402 curpar->lstyle = curtag.liststyle; \ 1411 curpar->remove( curpar->length()-2, 1 ); \
1403 curpar->litem = ( curtag.style->displayMode() == QStyleSheetItem::DisplayListItem ); \ 1412 curpar = createParagraph( this, curpar, curpar->next() ); styles.append( vec ); \
1404 curpar->str->setDirection( (QChar::Direction)curtag.direction ); \ 1413 if ( !curpar ) { \
1405 space = TRUE; \ 1414 owarn << "failed in creating a new paragraph" << oendl; \
1406 delete vec; vec = new QPtrVector<QStyleSheetItem>( (uint)tags.count() + 1); \ 1415 return; \
1407 int i = 0; \ 1416 } \
1408 for ( QValueStack<QTextDocumentTag>::Iterator it = tags.begin(); it != tags.end(); ++it ) \ 1417 vec = 0; \
1409 vec->insert( i++, (*it).style ); \ 1418 } \
1410 vec->insert( i, curtag.style ); \ 1419 hasNewPar = TRUE; \
1411 }while(FALSE) 1420 curpar->rtext = TRUE; \
1412 1421 curpar->align = curtag.alignment; \
1422 curpar->lstyle = curtag.liststyle; \
1423 curpar->litem = ( curtag.style->displayMode() == QStyleSheetItem::DisplayListItem ); \
1424 curpar->str->setDirection( (QChar::Direction)curtag.direction ); \
1425 space = TRUE; \
1426 delete vec; \
1427 vec = new QPtrVector<QStyleSheetItem>( (uint)tags.count() + 1); \
1428 int i = 0; \
1429 for ( QValueStack<QTextDocumentTag>::Iterator it = tags.begin(); it != tags.end(); ++it ) \
1430 vec->insert( i++, (*it).style ); \
1431 vec->insert( i, curtag.style ); \
1432 } while ( FALSE )
1413 1433
1414void QTextDocument::setRichText( const QString &text, const QString &context ) 1434void QTextDocument::setRichText( const QString &text, const QString &context )
1415{ 1435{
1416 if ( !context.isEmpty() ) 1436 if ( !context.isEmpty() )
1417 setContext( context ); 1437 setContext( context );
1418 clear(); 1438 clear();
@@ -1892,14 +1912,17 @@ void QTextDocument::setRichTextMarginsInternal( QPtrList< QPtrVector<QStyleSheet
1892 curStyle = nextStyle; 1912 curStyle = nextStyle;
1893 nextStyle = styles.next(); 1913 nextStyle = styles.next();
1894 continue; 1914 continue;
1895 } 1915 }
1896 1916
1897 int i, mar; 1917 int i, mar;
1898 QStyleSheetItem* mainStyle = curStyle->size() ? (*curStyle)[curStyle->size()-1] : 0; 1918 QStyleSheetItem* mainStyle = (*curStyle)[curStyle->size()-1];
1899 if ( mainStyle && mainStyle->displayMode() == QStyleSheetItem::DisplayListItem ) 1919 if ( !mainStyle )
1920 return;
1921
1922 if ( mainStyle->displayMode() == QStyleSheetItem::DisplayListItem )
1900 stylesPar->setListItem( TRUE ); 1923 stylesPar->setListItem( TRUE );
1901 int numLists = 0; 1924 int numLists = 0;
1902 for ( i = 0; i < (int)curStyle->size(); ++i ) { 1925 for ( i = 0; i < (int)curStyle->size(); ++i ) {
1903 if ( (*curStyle)[ i ]->displayMode() == QStyleSheetItem::DisplayBlock 1926 if ( (*curStyle)[ i ]->displayMode() == QStyleSheetItem::DisplayBlock
1904 && int((*curStyle)[ i ]->listStyle()) != QStyleSheetItem::Undefined ) 1927 && int((*curStyle)[ i ]->listStyle()) != QStyleSheetItem::Undefined )
1905 numLists++; 1928 numLists++;
@@ -5338,13 +5361,13 @@ int QTextFormatterBreakWords::format( QTextDocument *doc, QTextParagraph *parag,
5338 int ww = 0; 5361 int ww = 0;
5339 QChar lastChr; 5362 QChar lastChr;
5340 for ( ; i < len; ++i, ++col ) { 5363 for ( ; i < len; ++i, ++col ) {
5341 if ( c ) 5364 if ( c )
5342 lastChr = c->c; 5365 lastChr = c->c;
5343 // ### next line should not be needed 5366 // ### next line should not be needed
5344 if ( painter ) 5367 if ( c && painter )
5345 c->format()->setPainter( painter ); 5368 c->format()->setPainter( painter );
5346 c = &string->at( i ); 5369 c = &string->at( i );
5347 c->rightToLeft = FALSE; 5370 c->rightToLeft = FALSE;
5348 if ( i > 0 && (x > curLeft || ww == 0) || lastWasNonInlineCustom ) { 5371 if ( i > 0 && (x > curLeft || ww == 0) || lastWasNonInlineCustom ) {
5349 c->lineStart = 0; 5372 c->lineStart = 0;
5350 } else { 5373 } else {
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
@@ -292,12 +292,15 @@ UUIDVector OTSDPAttribute::getAllUUIDs() {
292 if (getType() == SEQUENCE) { 292 if (getType() == SEQUENCE) {
293 subAttributes = getSequence(); 293 subAttributes = getSequence();
294 } else if (getType() == ALTERNATIVE) { 294 } else if (getType() == ALTERNATIVE) {
295 subAttributes = getAlternative(); 295 subAttributes = getAlternative();
296 } 296 }
297 297
298 if (!subAttributes)
299 return 0;
300
298 int os; 301 int os;
299 for( unsigned int i = 0; i < subAttributes->count(); i++ ) { 302 for( unsigned int i = 0; i < subAttributes->count(); i++ ) {
300 UUIDVector subUUIDs = (*subAttributes)[i]->getAllUUIDs(); 303 UUIDVector subUUIDs = (*subAttributes)[i]->getAllUUIDs();
301 304
302 os = uuids.size(); 305 os = uuids.size();
303 uuids.resize( uuids.size()+subUUIDs.count() ); 306 uuids.resize( uuids.size()+subUUIDs.count() );
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
@@ -433,13 +433,15 @@ void OIpkgConfigDlg::initData()
433 } 433 }
434 } 434 }
435 } 435 }
436 } 436 }
437 437
438 // Get Ipkg execution options 438 // Get Ipkg execution options
439 int options = m_ipkg->ipkgExecOptions(); 439 int options = 0;
440 if ( m_ipkg )
441 options = m_ipkg->ipkgExecOptions();
440 if ( options & FORCE_DEPENDS ) 442 if ( options & FORCE_DEPENDS )
441 m_optForceDepends->setChecked( true ); 443 m_optForceDepends->setChecked( true );
442 if ( options & FORCE_REINSTALL ) 444 if ( options & FORCE_REINSTALL )
443 m_optForceReinstall->setChecked( true ); 445 m_optForceReinstall->setChecked( true );
444 if ( options & FORCE_REMOVE ) 446 if ( options & FORCE_REMOVE )
445 m_optForceRemove->setChecked( true ); 447 m_optForceRemove->setChecked( true );
@@ -447,13 +449,13 @@ void OIpkgConfigDlg::initData()
447 m_optForceOverwrite->setChecked( true ); 449 m_optForceOverwrite->setChecked( true );
448 if ( options & FORCE_RECURSIVE ) 450 if ( options & FORCE_RECURSIVE )
449 m_optForceRecursive->setChecked( true ); 451 m_optForceRecursive->setChecked( true );
450 if ( options & FORCE_VERBOSE_WGET ) 452 if ( options & FORCE_VERBOSE_WGET )
451 m_optVerboseWget->setChecked( true ); 453 m_optVerboseWget->setChecked( true );
452 454
453 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); 455 m_optVerboseIpkg->setCurrentItem( ( m_ipkg ? m_ipkg->ipkgExecVerbosity() : 0 ) );
454} 456}
455 457
456void OIpkgConfigDlg::slotServerSelected( int index ) 458void OIpkgConfigDlg::slotServerSelected( int index )
457{ 459{
458 m_serverCurrent = index; 460 m_serverCurrent = index;
459 461