From 1c6ef7a0c232d7c19b9689568335fc0c074fc09f Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 14 Sep 2023 00:05:47 -0400 Subject: [PATCH] check: fix memory leaks, kinda Looks like scope_free and scope_free_all are, uh, never used, so this isn't freed no matter what. But at least now we actually have the pointer so it *can* be freed, if we ever decide that maybe freeing things is actually a good idea idk Signed-off-by: Sebastian --- src/check.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/check.c b/src/check.c index 3f6fbe6..a3fcf3e 100644 --- a/src/check.c +++ b/src/check.c @@ -2445,12 +2445,12 @@ check_expr_propagate(struct context *ctx, struct scope *scope = scope_push(&ctx->scope, SCOPE_MATCH); struct match_case *case_ok = xcalloc(1, sizeof(struct match_case)); struct match_case *case_err = xcalloc(1, sizeof(struct match_case)); - struct identifier ok_name = {0}, err_name = {0}; - ok_name.name = gen_name(&ctx->id, "ok.%d"); - err_name.name = gen_name(&ctx->id, "err.%d"); const struct scope_object *ok_obj = NULL, *err_obj = NULL; if (result_type->size != 0 && result_type->size != SIZE_UNDEFINED) { + struct identifier ok_name = { + .name = gen_name(&ctx->id, "ok.%d"), + }; ok_obj = scope_insert(scope, O_BIND, &ok_name, &ok_name, result_type, NULL); } @@ -2479,6 +2479,9 @@ check_expr_propagate(struct context *ctx, }; } else { if (return_type->size != 0 && return_type->size != SIZE_UNDEFINED) { + struct identifier err_name = { + .name = gen_name(&ctx->id, "err.%d"), + }; err_obj = scope_insert(scope, O_BIND, &err_name, &err_name, return_type, NULL); } -- 2.45.2