From cea3203d8153136643aa1a749ba9c083899217e9 Mon Sep 17 00:00:00 2001 From: nishi Date: Sun, 5 May 2024 17:21:15 +0000 Subject: [PATCH] fix segfault git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@116 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- Serenade/interpreter.c | 2 +- Serenade/parser.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Serenade/interpreter.c b/Serenade/interpreter.c index d47d6a6..643e41c 100644 --- a/Serenade/interpreter.c +++ b/Serenade/interpreter.c @@ -269,8 +269,8 @@ void sn_interpreter_free(struct sn_interpreter* sn) { do_again: for(i = 0; sn->variables[i] != NULL; i++) { if(sn->variables[i] != NULL) { - free(sn->variables[i]->key); if(sn->variables[i]->value != NULL) { + free(sn->variables[i]->key); sn_generic_free(sn, sn->variables[i]->value); goto do_again; } diff --git a/Serenade/parser.c b/Serenade/parser.c index 58c4ba7..61591ff 100644 --- a/Serenade/parser.c +++ b/Serenade/parser.c @@ -245,6 +245,7 @@ void sn_generic_free(struct sn_interpreter* sn, struct sn_generic* g) { free(g->name); } if(sn == NULL) return; +regen:; int i; for(i = 0; sn->generics[i] != NULL; i++) ; @@ -276,10 +277,11 @@ void sn_generic_free(struct sn_interpreter* sn, struct sn_generic* g) { } gens[i][count] = NULL; free(oldgens[k]); + free(sn->generics); + sn->generics = gens; + goto regen; } } - free(sn->generics); - sn->generics = gens; if(sn->variables != NULL) { for(i = 0; sn->variables[i] != NULL; i++) -- 2.43.0