antlr3c/fix-hash-double-free.patch

34 lines
991 B
Diff
Raw Permalink Normal View History

From 6f5dad7d06620b4665303c542549d4c14f9fe784 Mon Sep 17 00:00:00 2001
From: Jiri Slaby <jirislaby@gmail.com>
Date: Sat, 19 Feb 2011 13:26:35 +0100
Subject: [PATCH] collections: hash, fix double free
We should not free the hash entry in antlr3HashFree when we didn't
strdup on that earlier.
I.e. make the free depend on table->doStrdup.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
src/antlr3collections.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/antlr3collections.c b/src/antlr3collections.c
index 01f3f7e..3e32dc3 100644
--- a/src/antlr3collections.c
+++ b/src/antlr3collections.c
@@ -237,7 +237,9 @@ antlr3HashFree(pANTLR3_HASH_TABLE table)
*/
if (entry->keybase.type == ANTLR3_HASH_TYPE_STR && entry->keybase.key.sKey != NULL)
{
- ANTLR3_FREE(entry->keybase.key.sKey);
+ if (table->doStrdup == ANTLR3_TRUE) {
+ ANTLR3_FREE(entry->keybase.key.sKey);
+ }
}
/* Free this entry
--
1.7.3.4