From fc62ec2a34baecf553ffadba2b7a27973c80e5e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Tue, 13 Mar 2012 02:39:10 +0000 Subject: [PATCH] [INTERPRETER] * BUG: INPUT does not leak memory anymore. git-svn-id: svn://localhost/gambas/trunk@4545 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/gbx/gbx_subr_file.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/main/gbx/gbx_subr_file.c b/main/gbx/gbx_subr_file.c index 98414ae36..65bec9d32 100755 --- a/main/gbx/gbx_subr_file.c +++ b/main/gbx/gbx_subr_file.c @@ -275,23 +275,30 @@ void SUBR_input(ushort code) stream = get_stream(PARAM, TRUE); if (stream) - { addr = STREAM_input(stream); - - VALUE_from_string(RETURN, addr, STRING_length(addr)); - - if (RETURN->type == T_NULL) - { - RETURN->type = T_STRING; - RETURN->_string.addr = addr; - RETURN->_string.start = 0; - RETURN->_string.len = STRING_length(addr); - } + else + addr = NULL; + + if (NPARAM == 1) + { + SP--; + if (!TYPE_is_integer(SP->type)) + RELEASE_OBJECT(SP); + } + + if (addr) + { + SP->type = T_STRING; + SP->_string.addr = addr; + SP->_string.start = 0; + SP->_string.len = STRING_length(addr); } else - RETURN->type = T_NULL; - - SUBR_LEAVE(); + { + SP->type = T_NULL; + } + + SP++; }