~sircmpwn/harec

1c6ef7a0c232d7c19b9689568335fc0c074fc09f — Sebastian 2 months ago 8ab07ee
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 <sebastian@sebsite.pw>
1 files changed, 6 insertions(+), 3 deletions(-)

M src/check.c
M src/check.c => src/check.c +6 -3
@@ 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);
		}