~lbnz/xr0

b4cd8a135f0ebca0976822283c8c4ea6b25adb68 — Amisi Kiarie a month ago 429d6ab fix/parameter-leaks
checkpoint
M src/state/stack.c => src/state/stack.c +7 -7
@@ 269,13 269,13 @@ stack_references(struct stack *s, struct location *loc, struct state *state)
		return true;
	}

	struct map *m = s->varmap;
	for (int i = 0; i < m->n; i++) {
		struct variable *var = (struct variable *) m->entry[i].value;
		if (variable_isparam(var) && variable_references(var, loc, state)) {
			return true;
		}
	}
	/*struct map *m = s->varmap;*/
	/*for (int i = 0; i < m->n; i++) {*/
		/*struct variable *var = (struct variable *) m->entry[i].value;*/
		/*if (variable_isparam(var) && variable_references(var, loc, state)) {*/
			/*return true;*/
		/*}*/
	/*}*/

	return false;
}

M src/state/state.c => src/state/state.c +2 -4
@@ 543,10 543,8 @@ state_equal(struct state *s1, struct state *s2)
{
	struct state *s1_c = state_copy(s1),
		     *s2_c = state_copy(s2);
	state_undeclareliterals(s1_c);
	state_undeclareliterals(s2_c);
	state_undeclarevars(s1_c);
	state_undeclarevars(s2_c);
	/*state_undeclarevars(s1_c);*/
	/*state_undeclarevars(s2_c);*/
	state_popprops(s1_c);
	state_popprops(s2_c);


A tests/0-basic/400-FAIL-param-leak.x => tests/0-basic/400-FAIL-param-leak.x +7 -0
@@ 0,0 1,7 @@
#include <stdlib.h>

void
leak(void *p) ~ [ p = malloc(1); ]
{
	p = malloc(1);
}

A tests/0-basic/400-FAIL-param-leak.x.EXPECTED => tests/0-basic/400-FAIL-param-leak.x.EXPECTED +1 -0
@@ 0,0 1,1 @@


A tests/0-basic/410-param-not-leak.x => tests/0-basic/410-param-not-leak.x +9 -0
@@ 0,0 1,9 @@
#include <stdlib.h>

void
notleak(void **p) ~ [
	setup: p = .clump(1);
	*p = malloc(1);
]{
	*p = malloc(1);
}