]> Nishi Git Mirror - serenade.git/commitdiff
fix segfault
authornishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Sun, 5 May 2024 17:21:15 +0000 (17:21 +0000)
committernishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Sun, 5 May 2024 17:21:15 +0000 (17:21 +0000)
git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@116 0f02c867-ac3d-714e-8a88-971ba1f6efcf

Serenade/interpreter.c
Serenade/parser.c

index d47d6a69faf9686532c57e3934e40bce65cb5ed3..643e41c60a524e7b0b018ea36f98697c0b262921 100644 (file)
@@ -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;
                        }
index 58c4ba76848afa5beb608fb2027ebd1147894f13..61591ff94ca90864c9c336ddf0581d40ca2d3fff 100644 (file)
@@ -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++)