Fix double free in swtch.c - scc - simple c99 compiler
HTML git clone git://git.simple-cc.org/scc
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 64470722a2a80a6b9144a79a162e11e8a0c2b7fb
DIR parent d5d0d662f6a48cf922d524b0df11911bde263fac
HTML Author: remph <lhr@disroot.org>
Date: Wed, 9 Apr 2025 16:15:48 +0100
Fix double free in swtch.c
The `list' pointer should be reset to NULL after the memory it points to
has been freed, otherwise the next time cleanswtch() is called it iterates
over the list starting at freed memory.
Diffstat:
M src/cmd/scc-cc/cc2/swtch.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
---
DIR diff --git a/src/cmd/scc-cc/cc2/swtch.c b/src/cmd/scc-cc/cc2/swtch.c
@@ -5,7 +5,7 @@
#include "cc2.h"
-static Swtch *list;
+static Swtch *list = NULL;
static Node *
swtch_if(Node *np)
@@ -147,4 +147,5 @@ cleanswtch(void)
}
free(p);
}
+ list = NULL;
}