summaryrefslogtreecommitdiff
path: root/noncore
authorerik <erik>2007-01-26 20:18:07 (UTC)
committer erik <erik>2007-01-26 20:18:07 (UTC)
commit152a8fe978851aea8dac6ae5cb11f73540746b83 (patch) (unidiff)
tree60f2fc2eb9a711e9aab91b9d743fd3730d5642e7 /noncore
parent644780047090442429342addb3fa97ec95bdc670 (diff)
downloadopie-152a8fe978851aea8dac6ae5cb11f73540746b83.zip
opie-152a8fe978851aea8dac6ae5cb11f73540746b83.tar.gz
opie-152a8fe978851aea8dac6ae5cb11f73540746b83.tar.bz2
Both files in this commit exhibit use after free errors.
One of them was introduced in my memory leak fixing (whoops). I was freeing a structure of stock data before one last call to it. So switching the free to after that call fixed it. The kcheckers.cpp fix is one where the game board could be deleted and then a new one is not created because someone attempted to request a game board type that is not supported. This is fixed by using the default directive for one of the game board types in the switch statement. Which means it could default to Russian boards. Score one for the Russians!
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kcheckers/kcheckers.cpp1
-rw-r--r--noncore/todayplugins/stockticker/libstocks/currency.c7
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/games/kcheckers/kcheckers.cpp b/noncore/games/kcheckers/kcheckers.cpp
index a27dd18..433c68f 100644
--- a/noncore/games/kcheckers/kcheckers.cpp
+++ b/noncore/games/kcheckers/kcheckers.cpp
@@ -409,48 +409,49 @@ void KCheckers::about()
409 "This program is distributed under the\n" 409 "This program is distributed under the\n"
410 "terms of the GNU General Public\n" 410 "terms of the GNU General Public\n"
411 "License."); 411 "License.");
412} 412}
413 413
414 414
415void KCheckers::aboutQt() 415void KCheckers::aboutQt()
416{ 416{
417 QMessageBox::aboutQt(this); 417 QMessageBox::aboutQt(this);
418} 418}
419 419
420 420
421void KCheckers::newGame() 421void KCheckers::newGame()
422{ 422{
423 if(game) delete game; 423 if(game) delete game;
424 424
425 switch(rules) 425 switch(rules)
426 { 426 {
427 case ENGLISH: 427 case ENGLISH:
428 game=new ECheckers(skill); 428 game=new ECheckers(skill);
429 CHECK_PTR(game); 429 CHECK_PTR(game);
430 break; 430 break;
431 431
432 case RUSSIAN: 432 case RUSSIAN:
433 default:
433 game=new RCheckers(skill); 434 game=new RCheckers(skill);
434 CHECK_PTR(game); 435 CHECK_PTR(game);
435 } 436 }
436 437
437 unselect(); 438 unselect();
438 gameOver=false; 439 gameOver=false;
439 440
440 gameMenu->setItemEnabled(undoID,false); 441 gameMenu->setItemEnabled(undoID,false);
441 undoButton->setEnabled(false); 442 undoButton->setEnabled(false);
442 443
443 colorChange(); 444 colorChange();
444 445
445 for(int i=0;i<32;i++) drawBoard(i); 446 for(int i=0;i<32;i++) drawBoard(i);
446 if(optionsMenu->isItemChecked(numID)) drawNumeration(); 447 if(optionsMenu->isItemChecked(numID)) drawNumeration();
447 448
448 if(!userFirst) compGo(); 449 if(!userFirst) compGo();
449 450
450 statusLabel->setText(tr("Go!")); 451 statusLabel->setText(tr("Go!"));
451} 452}
452 453
453 454
454// Undo the last computer and user moves 455// Undo the last computer and user moves
455 456
456void KCheckers::undoMove() 457void KCheckers::undoMove()
diff --git a/noncore/todayplugins/stockticker/libstocks/currency.c b/noncore/todayplugins/stockticker/libstocks/currency.c
index e0090e2..82cd654 100644
--- a/noncore/todayplugins/stockticker/libstocks/currency.c
+++ b/noncore/todayplugins/stockticker/libstocks/currency.c
@@ -35,33 +35,32 @@
35libstocks_return_code get_currency_exchange(char *from, 35libstocks_return_code get_currency_exchange(char *from,
36 char *into, 36 char *into,
37 float *exchange) 37 float *exchange)
38{ 38{
39 char *symbol; 39 char *symbol;
40 stock *data; 40 stock *data;
41 libstocks_return_code error; 41 libstocks_return_code error;
42 42
43 if((symbol = (char *)malloc(strlen(from)+strlen(into)+3))==NULL) 43 if((symbol = (char *)malloc(strlen(from)+strlen(into)+3))==NULL)
44 { 44 {
45 fprintf(stderr,"Memory allocating error (%s line %d)\n" 45 fprintf(stderr,"Memory allocating error (%s line %d)\n"
46 ,__FILE__, __LINE__); 46 ,__FILE__, __LINE__);
47 exit(1); 47 exit(1);
48 } 48 }
49 49
50 strcpy(symbol, from); 50 strcpy(symbol, from);
51 strcat(symbol, into); 51 strcat(symbol, into);
52 strcat(symbol, "=X"); 52 strcat(symbol, "=X");
53 53
54 error = get_stocks(symbol, &data); 54 error = get_stocks(symbol, &data);
55 free(symbol); 55 free(symbol);
56 if (error) 56 if (error)
57 { 57 {
58 *exchange = 0; 58 *exchange = 0;
59 return(error); 59 return error;
60 } 60 }
61 61
62 free_stocks(data);
63
64 *exchange = data->CurrentPrice; 62 *exchange = data->CurrentPrice;
65 return(error); 63 free_stocks(data);
64 return error;
66 65
67} 66}