From b5edf09de9b4d0be2f532b7f97958b24384fec13 Mon Sep 17 00:00:00 2001 From: gambas Date: Wed, 23 May 2018 20:39:16 +0200 Subject: [PATCH] Reading a fixed number of bytes with READ does not crash anymore if an "End of file" error is raised. [INTERPRETER] * BUG: Reading a fixed number of bytes with READ does not crash anymore if an "End of file" error is raised. --- main/gbx/gbx_string.c | 3 +-- main/gbx/gbx_subr_file.c | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/main/gbx/gbx_string.c b/main/gbx/gbx_string.c index 1a7ad3e2b..930ddacfa 100644 --- a/main/gbx/gbx_string.c +++ b/main/gbx/gbx_string.c @@ -461,8 +461,7 @@ bool STRING_extend_will_realloc(char *str, int new_len) void STRING_new_temp_value(VALUE *value, const char *src, int len) { value->_string.addr = STRING_new_temp(src, len); - - value->_string.len = STRING_length(value->_string.addr); + value->_string.len = len; //STRING_length(value->_string.addr); value->_string.start = 0; value->type = T_STRING; } diff --git a/main/gbx/gbx_subr_file.c b/main/gbx/gbx_subr_file.c index 740b1a5ba..35ce5186a 100755 --- a/main/gbx/gbx_subr_file.c +++ b/main/gbx/gbx_subr_file.c @@ -473,7 +473,11 @@ void SUBR_read(ushort code) } else if (len > 0) { - STRING_new_temp_value(RETURN, NULL, len); + RETURN->type = T_STRING; + RETURN->_string.addr = STRING_new(NULL, len); + RETURN->_string.start = 0; + RETURN->_string.len = len; + STREAM_read(stream, RETURN->_string.addr, len); } else