diff options
author | Thomas Günther <tom@toms-cafe.de> | 2010-03-31 02:43:17 +0200 |
---|---|---|
committer | Thomas Günther <tom@toms-cafe.de> | 2010-03-31 02:43:17 +0200 |
commit | f3821d76d95576ff1be0dc3de4b74cdf70049a8d (patch) | |
tree | 3c2167895eebcb9213be1437f139b90de531265e | |
parent | 792a9e477954373d300e22615126acd8e3d5af7c (diff) | |
download | vdr-plugin-sudoku-f3821d76d95576ff1be0dc3de4b74cdf70049a8d.tar.gz vdr-plugin-sudoku-f3821d76d95576ff1be0dc3de4b74cdf70049a8d.tar.bz2 |
Fixed null pointer handling in History::add
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | history.cpp | 15 |
2 files changed, 10 insertions, 6 deletions
@@ -97,3 +97,4 @@ ____-__-__: Version 0.3.5 - Converted documentation and source files to UTF-8. - Added unit tests. - Fixed segfault in History::current. +- Fixed null pointer handling in History::add. diff --git a/history.cpp b/history.cpp index d89d0d5..65e3a5f 100644 --- a/history.cpp +++ b/history.cpp @@ -61,14 +61,17 @@ Move* History::current() /** Add a new move */ void History::add(Move* move) { - for (unsigned int pos = history.size(); pos > executed; --pos) + if (move) { - // Remove object created outside of History - delete history.back(); - history.pop_back(); + for (unsigned int pos = history.size(); pos > executed; --pos) + { + // Remove object created outside of History + delete history.back(); + history.pop_back(); + } + history.push_back(move); + ++executed; } - history.push_back(move); - ++executed; } /** Set previous move as current */ |