summaryrefslogtreecommitdiff
authorerik <erik>2007-01-24 19:54:07 (UTC)
committer erik <erik>2007-01-24 19:54:07 (UTC)
commit89e81059e832ff77c2f0ac8b9db12f80eafa03fc (patch) (side-by-side diff)
tree99a130fc643d2aeefdecab452f644e7b61a5f50e
parent035bbc5bf689839c8d8e7be37f347b0dd900fccf (diff)
downloadopie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.zip
opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.tar.gz
opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.tar.bz2
Each file in this commit has an instance where a pointer is checked at
one point in the code and then not checked in another point in the code. If it needed to be checked once, it needs to be checked the other time. If not the application could segfault.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opieui/big-screen/osplitter.cpp2
-rw-r--r--library/qpeapplication.cpp6
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp6
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp3
-rw-r--r--noncore/apps/opie-console/procctl.cpp3
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp63
-rw-r--r--noncore/settings/sysinfo/devicesinfo.cpp2
-rw-r--r--noncore/todayplugins/stockticker/libstocks/http.c2
8 files changed, 48 insertions, 39 deletions
diff --git a/libopie2/opieui/big-screen/osplitter.cpp b/libopie2/opieui/big-screen/osplitter.cpp
index 78e919a..5d1e2cf 100644
--- a/libopie2/opieui/big-screen/osplitter.cpp
+++ b/libopie2/opieui/big-screen/osplitter.cpp
@@ -226,9 +226,9 @@ void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& lab
else
{
if (m_hbox )
addToBox( cont );
- else
+ else if (m_tabWidget)
addToTab( cont );
}
}
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 34f5e6a..d959c7a 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1768,15 +1768,15 @@ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
\sa showMainWidget()
*/
void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
{
- if ( mw && argc() == 2 )
+ if ( mw ) {
+ if ( argc() == 2 )
Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
-
-// setMainWidget(mw); see above
d->show(mw, nomaximize );
}
+}
/*!
If an application is started via a \link qcop.html QCop\endlink
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 187adc6..c639002 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -235,8 +235,14 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
}
if ( !newCard ) ++it; else break;
}
}
+
+ if ( !theCard ) {
+ owarn << "pcmcia: Finished working through cards in PCMCIA system but I do not have a valid card handle" << oendl;
+ return;
+ }
+
if ( newCard )
{
odebug << "pcmcia: unconfigured card detected" << oendl;
QString newCardName = theCard->productIdentity();
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index d9e2047..8e2e2e3 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -242,8 +242,9 @@ void MainWindow::slotEdit()
// --- openBook ---------------------------------------------------------------
void MainWindow::openBook(QListViewItem *curritem)
{
+ if ( !curritem ) return;
// find book in List
QString currname=curritem->text(posName);
CBInfo *cb = checkbooks->first();
while ( cb ) {
@@ -276,12 +277,10 @@ void MainWindow::openBook(QListViewItem *curritem)
QString newname = cb->name();
if ( currname != newname )
{
// Update name if changed
- if( curritem ) {
curritem->setText( posName, newname );
cbList->sort();
- }
_cfg.setLastBook( newname );
// Remove old file
QFile f( tempFilename );
diff --git a/noncore/apps/opie-console/procctl.cpp b/noncore/apps/opie-console/procctl.cpp
index a44529b..5239e26 100644
--- a/noncore/apps/opie-console/procctl.cpp
+++ b/noncore/apps/opie-console/procctl.cpp
@@ -48,9 +48,12 @@ void ProcCtl::remove( pid_t pi ) {
ProcContainer* forw = 0l;
while (con ) {
/* remove it */
if ( pi == con->pid ) {
+ if (forw)
forw->prev = con->prev;
+ else
+ forw = con->prev;
delete con;
return;
}
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp
index b82a86a..692fd46 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp
@@ -2014,9 +2014,9 @@ void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, i
int len;
const QChar *s;
int z, x;
QChar ch;
- Attribute *a = 0L;
+ Attribute *attrptr = 0L;
int attr, nextAttr;
int xs;
int xc, zc;
@@ -2039,15 +2039,15 @@ void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, i
ch = s[z];//textLine->getChar(z);
if (ch == '\t') {
x += m_tabWidth - (x % m_tabWidth);
} else {
- a = &m_attribs[textLine->getAttr(z)];
+ attrptr = &m_attribs[textLine->getAttr(z)];
- if (a->bold && a->italic)
+ if (attrptr->bold && attrptr->italic)
x += myFontMetricsBI.width(ch);
- else if (a->bold)
+ else if (attrptr->bold)
x += myFontMetricsBold.width(ch);
- else if (a->italic)
+ else if (attrptr->italic)
x += myFontMetricsItalic.width(ch);
else
x += myFontMetrics.width(ch);
}
@@ -2078,15 +2078,15 @@ void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, i
if (ch == '\t')
x += m_tabWidth - (x % m_tabWidth);
else
{
- a = &m_attribs[textLine->getAttr(z)];
+ attrptr = &m_attribs[textLine->getAttr(z)];
- if (a->bold && a->italic)
+ if (attrptr->bold && attrptr->italic)
x += myFontMetricsBI.width(ch);
- else if (a->bold)
+ else if (attrptr->bold)
x += myFontMetricsBold.width(ch);
- else if (a->italic)
+ else if (attrptr->italic)
x += myFontMetricsItalic.width(ch);
else
x += myFontMetrics.width(ch);
}
@@ -2113,13 +2113,13 @@ void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, i
QConstString str((QChar *) &s[zc], z - zc /*+1*/);
QString s = str.string();
paint.drawText(x - xStart, y, s);
- if (a->bold && a->italic)
+ if (attrptr && attrptr->bold && attrptr->italic)
x += myFontMetricsBI.width(s);
- else if (a->bold)
+ else if (attrptr && attrptr->bold)
x += myFontMetricsBold.width(s);
- else if (a->italic)
+ else if (attrptr && attrptr->italic)
x += myFontMetricsItalic.width(s);
else
x += myFontMetrics.width(s);
}
@@ -2128,25 +2128,23 @@ void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, i
if (showTabs) {
nextAttr = textLine->getRawAttr(z);
if (nextAttr != attr) {
attr = nextAttr;
- a = &m_attribs[attr & taAttrMask];
+ attrptr = &m_attribs[attr & taAttrMask];
- if (attr & taSelected) paint.setPen(a->selCol);
- else paint.setPen(a->col);
+ if (attr & taSelected) paint.setPen(attrptr->selCol);
+ else paint.setPen(attrptr->col);
- if (a->bold && a->italic)
+ if (attrptr->bold && attrptr->italic)
paint.setFont(myFontBI);
- else if (a->bold)
+ else if (attrptr->bold)
paint.setFont(myFontBold);
- else if (a->italic)
+ else if (attrptr->italic)
paint.setFont(myFontItalic);
else
paint.setFont(myFont);
}
-// paint.drawLine(x - xStart, y -2, x - xStart, y);
-// paint.drawLine(x - xStart, y, x - xStart + 2, y);
paint.drawPoint(x - xStart, y);
paint.drawPoint(x - xStart +1, y);
paint.drawPoint(x - xStart, y -1);
}
@@ -2158,29 +2156,29 @@ void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, i
QConstString str((QChar *) &s[zc], z - zc /*+1*/);
QString s = str.string();
paint.drawText(x - xStart, y, s);
- if (a->bold && a->italic)
+ if (attrptr->bold && attrptr->italic)
x += myFontMetricsBI.width(s);
- else if (a->bold)
+ else if (attrptr->bold)
x += myFontMetricsBold.width(s);
- else if (a->italic)
+ else if (attrptr->italic)
x += myFontMetricsItalic.width(s);
else
x += myFontMetrics.width(s);
zc = z;
}
attr = nextAttr;
- a = &m_attribs[attr & taAttrMask];
+ attrptr = &m_attribs[attr & taAttrMask];
- if (attr & taSelected) paint.setPen(a->selCol);
- else paint.setPen(a->col);
+ if (attr & taSelected) paint.setPen(attrptr->selCol);
+ else paint.setPen(attrptr->col);
- if (a->bold && a->italic)
+ if (attrptr->bold && attrptr->italic)
paint.setFont(myFontBI);
- else if (a->bold)
+ else if (attrptr->bold)
paint.setFont(myFontBold);
- else if (a->italic)
+ else if (attrptr->italic)
paint.setFont(myFontItalic);
else
paint.setFont(myFont);
}
@@ -2226,9 +2224,11 @@ bool KateDocument::doSearch(SConfig &sc, const QString &searchFor) {
if (tlen > bufLen) {
delete [] t;
bufLen = (tlen + 255) & (~255);
t = new QChar[bufLen];
- }
+ } else if (!t)
+ t = new QChar[bufLen];
+
memcpy(t, textLine->getText(), tlen*sizeof(QChar));
if (sc.flags & KateView::sfSelected) {
pos = 0;
do {
@@ -2287,9 +2287,10 @@ bool KateDocument::doSearch(SConfig &sc, const QString &searchFor) {
if (tlen > bufLen) {
delete [] t;
bufLen = (tlen + 255) & (~255);
t = new QChar[bufLen];
- }
+ } else if (!t)
+ t = new QChar[bufLen];
memcpy(t, textLine->getText(), tlen*sizeof(QChar));
if (sc.flags & KateView::sfSelected) {
pos = 0;
do {
diff --git a/noncore/settings/sysinfo/devicesinfo.cpp b/noncore/settings/sysinfo/devicesinfo.cpp
index 164d608..428cfd4 100644
--- a/noncore/settings/sysinfo/devicesinfo.cpp
+++ b/noncore/settings/sysinfo/devicesinfo.cpp
@@ -264,9 +264,9 @@ void UsbCategory::populate()
dev = new UsbDevice( lastDev, QString( "Generic USB Hub Device" ) );
lastDev = dev;
}
}
- else if ( line.startsWith( "S: Product" ) )
+ else if ( dev && line.startsWith( "S: Product" ) )
{
int dp = line.find( '=' );
dev->setText( 0, dp != -1 ? line.right( line.length()-1-dp ) : "<unknown>" );
}
diff --git a/noncore/todayplugins/stockticker/libstocks/http.c b/noncore/todayplugins/stockticker/libstocks/http.c
index 2f38f8a..cc78ab7 100644
--- a/noncore/todayplugins/stockticker/libstocks/http.c
+++ b/noncore/todayplugins/stockticker/libstocks/http.c
@@ -209,9 +209,9 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata)
temp = data;
header_founded = 0;
while( !header_founded )
{
- if (*temp==0) return ERRRHEA;
+ if (!temp || *temp==0) return ERRRHEA;
if( *temp==0x0A )
{
/* test if it is the header end */