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.
This commit is contained in:
gambas 2018-05-23 20:39:16 +02:00
parent 8200600168
commit b5edf09de9
2 changed files with 6 additions and 3 deletions

View File

@ -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;
}

View File

@ -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