summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY1
-rw-r--r--history.cpp15
2 files changed, 10 insertions, 6 deletions
diff --git a/HISTORY b/HISTORY
index a4397ba..56c2d35 100644
--- a/HISTORY
+++ b/HISTORY
@@ -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 */