BR 877583: Fix RAA memory leak
authorH. Peter Anvin <hpa@zytor.com>
Mon, 19 Nov 2007 20:02:38 +0000 (12:02 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Mon, 19 Nov 2007 20:02:38 +0000 (12:02 -0800)
raa_free() didn't actually do the proper job; it would only free leaf
nodes, not internal nodes.

nasmlib.c

index 6f59820..5c3601e 100644 (file)
--- a/nasmlib.c
+++ b/nasmlib.c
@@ -474,14 +474,13 @@ struct RAA *raa_init(void)
 
 void raa_free(struct RAA *r)
 {
-    if (r->layers == 0)
-        nasm_free(r);
-    else {
+    if (r->layers) {
         struct RAA **p;
         for (p = r->u.b.data; p - r->u.b.data < RAA_LAYERSIZE; p++)
             if (*p)
                 raa_free(*p);
     }
+    nasm_free(r);
 }
 
 int64_t raa_read(struct RAA *r, int32_t posn)