aboutsummaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-10 13:29:30 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-10 13:29:30 -0800
commita44938c6b17456edb47b0dafb720c00700de3fac (patch)
tree071dc4ea26143ffc0aae1a0ed965f90f730bc4cc /vm.c
parent421880be128dc9614b4d194991bdd47d61af78b8 (diff)
Mitigation of memory leak
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index 68ff79a..6969c55 100644
--- a/vm.c
+++ b/vm.c
@@ -363,6 +363,14 @@ static match_t *_match(def_t *defs, file_t *f, const char *str, vm_op_t *op, uns
while (defs2 != defs) {
def_t *next = defs2->next;
defs2->next = NULL;
+ // Deliberate memory leak, if there is a match, then the op
+ // will be stored on the match and can't be freed here.
+ // There's currently no refcounting on ops but that should
+ // be how to prevent a memory leak from this.
+ // TODO: add refcounting to ops?
+ if (m2 == NULL) {
+ xfree(&defs2->op);
+ }
xfree(&defs2);
defs2 = next;
}