summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/newgrf_storage.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/newgrf_storage.h b/src/newgrf_storage.h
index f5044b05d..528d4ff3c 100644
--- a/src/newgrf_storage.h
+++ b/src/newgrf_storage.h
@@ -84,7 +84,7 @@ struct PersistentStorageArray : BaseStorageArray {
if (this->storage[pos] == value) return;
/* We do not have made a backup; lets do so */
- if (this->prev_storage != NULL) {
+ if (this->prev_storage == NULL) {
this->prev_storage = MallocT<TYPE>(SIZE);
memcpy(this->prev_storage, this->storage, sizeof(this->storage));
@@ -121,6 +121,7 @@ struct PersistentStorageArray : BaseStorageArray {
memcpy(this->storage, this->prev_storage, sizeof(this->storage));
}
free(this->prev_storage);
+ this->prev_storage = NULL;
}
};