From be70a70eaae6d391b0524e316eac6ad173d9e14b Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 18 Jan 2011 14:51:05 +0000 Subject: [PATCH] Fix a refcount bug in the entity dictionary. --- src/dict.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/dict.cpp b/src/dict.cpp index 950e37fa..9a3e77a9 100644 --- a/src/dict.cpp +++ b/src/dict.cpp @@ -40,8 +40,10 @@ public: ~DictData() { +#if !FINAL_RELEASE if (nentities) fprintf(stderr, "ERROR: still %i entities in dict\n", nentities); +#endif free(entities); } @@ -103,8 +105,15 @@ int Dict::MakeSlot(char const *name) void Dict::RemoveSlot(int id) { if (Ticker::Unref(data->entities[id]) == 0) + { data->entities[id] = NULL; - data->nentities--; + if (data->nentities) + data->nentities--; +#if !FINAL_RELEASE + else + fprintf(stderr, "ERROR: removing entity from empty dict\n"); +#endif + } }