From 15215211162ef4e54f79d6dda8472cf1aa85cfe2 Mon Sep 17 00:00:00 2001 From: mainzelm Date: Mon, 13 Oct 2003 09:50:30 +0000 Subject: [PATCH] Fixed memory leak in scheme_cwd: a temporary buffer was not freed after entering the value in the scheme heap. --- scsh/syscalls1.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scsh/syscalls1.c b/scsh/syscalls1.c index c253239..5515be6 100644 --- a/scsh/syscalls1.c +++ b/scsh/syscalls1.c @@ -335,6 +335,7 @@ s48_value scheme_cwd() { char *buf; int size = scsh_path_max + 1; /* +1 for terminating nul byte... */ + s48_value cwd = S48_UNSPECIFIC; buf = Malloc(char,size); if(!buf) goto lose; @@ -347,8 +348,11 @@ s48_value scheme_cwd() if( !nbuf ) goto lose; buf = nbuf; } - - return s48_enter_string(buf); /* win */ + cwd = s48_enter_string(buf); /* win */ + + Free(buf); + + return cwd; lose: {int e = errno;