klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit bcd9a93ad84db454df531452eebbcf4fd800dcb0
parent 2a62e746ab8ae1896129b6c056461d2229248af8
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Wed, 20 Apr 2011 01:33:26 -0300

Bugfix: in throw_extra there was an extra byte attached to the msg buffer.

Diffstat:
Msrc/Makefile | 2+-
Msrc/kerror.c | 8++++----
Msrc/kstate.c | 4+++-
3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/Makefile b/src/Makefile @@ -59,7 +59,7 @@ kwrite.o: kwrite.c kwrite.h kobject.h kpair.h kstring.h kstate.h kerror.h \ kstate.o: kstate.c kstate.h klisp.h kobject.h kmem.h kstring.h klisp.h \ kenvironment.h kpair.h keval.h koperative.h kground.h \ krepl.h kcontinuation.h kapplicative.h kport.h ksymbol.h kport.h \ - kstring.h kinteger.h kgc.h + kstring.h kinteger.h kgc.h klimits.h kmem.o: kmem.c kmem.h klisp.h kerror.h klisp.h kstate.h kgc.h klispconf.h kerror.o: kerror.c kerror.h klisp.h kstate.h klisp.h kmem.h kstring.h kpair.h kauxlib.o: kauxlib.c kauxlib.h klisp.h kstate.h klisp.h diff --git a/src/kerror.c b/src/kerror.c @@ -36,7 +36,6 @@ void klispE_throw(klisp_State *K, char *msg) TValue error_msg = kstring_new_b_imm(K, msg); /* TEMP */ clear_buffers(K); - kcall_cont(K, K->error_cont, error_msg); } @@ -46,15 +45,16 @@ void klispE_throw_extra(klisp_State *K, char *msg, char *extra_msg) { int32_t l1 = strlen(msg); int32_t l2 = strlen(extra_msg); - int32_t tl = l1+l2+1; + int32_t tl = l1+l2; - char *msg_buf = klispM_malloc(K, tl); + char *msg_buf = klispM_malloc(K, tl+1); strcpy(msg_buf, msg); strcpy(msg_buf+l1, extra_msg); + msg_buf[tl] = '\0'; /* if the mem allocator could throw errors, this could potentially leak msg_buf */ TValue error_msg = kstring_new_bs_imm(K, msg_buf, tl); - klispM_freemem(K, msg_buf, tl); + klispM_freemem(K, msg_buf, tl+1); clear_buffers(K); diff --git a/src/kstate.c b/src/kstate.c @@ -17,6 +17,7 @@ #include <setjmp.h> #include "klisp.h" +#include "klimits.h" #include "kstate.h" #include "kobject.h" #include "kstring.h" @@ -178,7 +179,8 @@ klisp_State *klisp_newstate (klisp_Alloc f, void *ud) { K->eval_op = kmake_operative(K, keval_ofn, 0); K->list_app = kmake_applicative(K, list, 0); /* ground environment has a hashtable for bindings */ - K->ground_env = kmake_table_environment(K, KNIL); +// K->ground_env = kmake_table_environment(K, KNIL); + K->ground_env = kmake_environment(K, KNIL); /* MAYBE: fix it so we can remove module_params_sym from roots */ K->module_params_sym = ksymbol_new(K, "module-parameters");