On Mon, Aug 25, 2008 at 17:10:25 +0200, Julien Cristau wrote:
> Looking at frame 3:
> #3 0x080f83a5 in StateMainMenu::updateStats (this=0x8872d10)
> at states/StateMainMenu.cpp:700
> 700 v_totalPlayedTime = atoi(pDb->getResult(v_result, 8, 0, 2));
>
> (gdb) p pDb->getResult(v_result, 8, 0, 2)
> $3 = 0x0
>
The attached patch was enough to make xmoto start without segfaulting
here.
Cheers,
Julien
diff -u xmoto-0.4.2/debian/changelog xmoto-0.4.2/debian/changelog
--- xmoto-0.4.2/debian/changelog
+++ xmoto-0.4.2/debian/changelog
@@ -1,3 +1,10 @@
+xmoto (0.4.2-2) UNRELEASED; urgency=low
+
+ * Don't call atoi(NULL), fixes segfault on upgrade from etch
+ (closes: #492414)
+
+ -- Julien Cristau <[EMAIL PROTECTED]> Mon, 25 Aug 2008 17:21:36 +0200
+
xmoto (0.4.2-1) unstable; urgency=low
* New upstream release.
only in patch2:
unchanged:
--- xmoto-0.4.2.orig/src/svnVersion
+++ xmoto-0.4.2/src/svnVersion
@@ -0,0 +1 @@
+exported
only in patch2:
unchanged:
--- xmoto-0.4.2.orig/src/states/StateMainMenu.cpp
+++ xmoto-0.4.2/src/states/StateMainMenu.cpp
@@ -673,6 +673,7 @@
int v_nbDiffLevels = 0;
std::string v_level_name= "";
xmDatabase* pDb = xmDatabase::instance("main");
+ char *tmpresult;
if(v_window != NULL){
delete v_window;
@@ -695,14 +696,21 @@
return;
}
- v_nbStarts = atoi(pDb->getResult(v_result, 8, 0, 0));
+ tmpresult = pDb->getResult(v_result, 8, 0, 0);
+ v_nbStarts = tmpresult ? atoi(tmpresult) : 0;
v_since = pDb->getResult(v_result, 8, 0, 1);
- v_totalPlayedTime = atoi(pDb->getResult(v_result, 8, 0, 2));
- v_nbPlayed = atoi(pDb->getResult(v_result, 8, 0, 3));
- v_nbDied = atoi(pDb->getResult(v_result, 8, 0, 4));
- v_nbCompleted = atoi(pDb->getResult(v_result, 8, 0, 5));
- v_nbRestarted = atoi(pDb->getResult(v_result, 8, 0, 6));
- v_nbDiffLevels = atoi(pDb->getResult(v_result, 8, 0, 7));
+ tmpresult = pDb->getResult(v_result, 8, 0, 2);
+ v_totalPlayedTime = tmpresult ? atoi(tmpresult) : 0;
+ tmpresult = pDb->getResult(v_result, 8, 0, 3);
+ v_nbPlayed = tmpresult ? atoi(tmpresult) : 0;
+ tmpresult = pDb->getResult(v_result, 8, 0, 4);
+ v_nbDied = tmpresult ? atoi(tmpresult) : 0;
+ tmpresult = pDb->getResult(v_result, 8, 0, 5);
+ v_nbCompleted = tmpresult ? atoi(tmpresult) : 0;
+ tmpresult = pDb->getResult(v_result, 8, 0, 6);
+ v_nbRestarted = tmpresult ? atoi(tmpresult) : 0;
+ tmpresult = pDb->getResult(v_result, 8, 0, 7);
+ v_nbDiffLevels = tmpresult ? atoi(tmpresult) : 0;
pDb->read_DB_free(v_result);
@@ -754,11 +762,16 @@
if(cy + 45 > nHeight) break; /* out of window */
v_level_name = pDb->getResult(v_result, 6, i, 0);
- v_totalPlayedTime = atoi(pDb->getResult(v_result, 6, i, 5));
- v_nbDied = atoi(pDb->getResult(v_result, 6, i, 2));
- v_nbPlayed = atoi(pDb->getResult(v_result, 6, i, 1));
- v_nbCompleted = atoi(pDb->getResult(v_result, 6, i, 3));
- v_nbRestarted = atoi(pDb->getResult(v_result, 6, i, 4));
+ tmpresult = pDb->getResult(v_result, 6, i, 5);
+ v_totalPlayedTime = tmpresult ? atoi(tmpresult) : 0;
+ tmpresult = pDb->getResult(v_result, 6, i, 2);
+ v_nbDied = tmpresult ? atoi(tmpresult) : 0;
+ tmpresult = pDb->getResult(v_result, 6, i, 1);
+ v_nbPlayed = tmpresult ? atoi(tmpresult) : 0;
+ tmpresult = pDb->getResult(v_result, 6, i, 3);
+ v_nbCompleted = tmpresult ? atoi(tmpresult) : 0;
+ tmpresult = pDb->getResult(v_result, 6, i, 4);
+ v_nbRestarted = tmpresult ? atoi(tmpresult) : 0;
snprintf(cBuf, 512, ("[%s] %s:\n " +
std::string(GAMETEXT_XMOTOLEVELSTATS_PLAYS(v_nbPlayed) + std::string(",
") +
GAMETEXT_XMOTOLEVELSTATS_DEATHS(v_nbDied) + std::string(", ") +