leak fix for scripted returns

master
Clyne Sullivan 7 years ago
parent 7b08dbbbe9
commit 0fb67b8d66

@ -16,4 +16,4 @@ all:
$(CC) $(CFLAGS) -c variable.c $(CC) $(CFLAGS) -c variable.c
$(AR) r libinterp.a *.o $(AR) r libinterp.a *.o
@rm -f *.o @rm -f *.o
#$(CC) $(CFLAGS) shell.c *.o -o shell #-L. -l interp #$(CC) $(CFLAGS) shell.c *.o -o shell

@ -94,15 +94,13 @@ int ifunc_do(interpreter *it)
int ifunc_while(interpreter *it) int ifunc_while(interpreter *it)
{ {
//int c = igetarg_integer(it, 0); int c = igetarg_integer(it, 0);
ipop(it); ipop(it);
int nidx = (int)ipop(it); int nidx = (int)ipop(it);
//if (c != 0) { if (c != 0) {
//ipush(it, (void *)nidx); //ipush(it, (void *)nidx);
it->lnidx = nidx - 1; it->lnidx = nidx - 1;
//} else { }
// c++;
//}
ipush(it, 0); ipush(it, 0);
return 0; return 0;
} }
@ -126,7 +124,10 @@ void iret(interpreter *it, variable *v)
if (it->ret != 0) { if (it->ret != 0) {
it->ret->valtype = v->valtype; it->ret->valtype = v->valtype;
it->ret->value = v->value; it->ret->value = v->value;
it->ret->svalue = v->svalue; char *s = it->ret->svalue;
if (s != 0 && s != str_undef)
free(s);
it->ret->svalue = strclone(v->svalue);
it->ret = 0; it->ret = 0;
} }
} }

@ -39,9 +39,9 @@ void iend(interpreter *it)
{ {
for (unsigned int i = 0; i < MAX_VARS; i++) { for (unsigned int i = 0; i < MAX_VARS; i++) {
if (it->vars[i].used == 1) { if (it->vars[i].used == 1) {
char *s = it->vars[i].svalue; //char *s = it->vars[i].svalue;
if (s != 0 && s != str_undef && s != str_func) //if (s != 0 && s != str_undef && s != str_func)
free(s); // free(s);
free(it->vnames[i]); free(it->vnames[i]);
} }
} }

Loading…
Cancel
Save