From e1202bad7e3c96ad796adb5e221e9df05a72404b Mon Sep 17 00:00:00 2001 From: gambas Date: Thu, 10 Jun 2021 02:27:09 +0200 Subject: [PATCH] Array.Read() and Array.Write() now check their stream argument instead of crashing if it is NULL. [INTERPRETER] * BUG: Array.Read() and Array.Write() now check their stream argument instead of crashing if it is NULL. --- main/gbx/gbx_c_array.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/main/gbx/gbx_c_array.c b/main/gbx/gbx_c_array.c index 6673d77c1..8c026d3a1 100644 --- a/main/gbx/gbx_c_array.c +++ b/main/gbx/gbx_c_array.c @@ -1686,30 +1686,38 @@ BEGIN_METHOD_VOID(CARRAY_reverse) END_METHOD -BEGIN_METHOD(Array_Read, GB_OBJECT file; GB_INTEGER start; GB_INTEGER length) +BEGIN_METHOD(Array_Read, GB_OBJECT stream; GB_INTEGER start; GB_INTEGER length) int count = THIS->count; int start = VARGOPT(start, 0); int length = VARGOPT(length, count); + void *stream = VARG(stream); + + if (GB_CheckObject(stream)) + return; if (check_start_length(count, &start, &length)) return; - STREAM_read(CSTREAM_TO_STREAM(VARG(file)), get_data(THIS, start), length * THIS->size); + STREAM_read(CSTREAM_TO_STREAM(stream), get_data(THIS, start), length * THIS->size); END_METHOD -BEGIN_METHOD(Array_Write, GB_OBJECT file; GB_INTEGER start; GB_INTEGER length) +BEGIN_METHOD(Array_Write, GB_OBJECT stream; GB_INTEGER start; GB_INTEGER length) int count = THIS->count; int start = VARGOPT(start, 0); int length = VARGOPT(length, count); + void *stream = VARG(stream); + + if (GB_CheckObject(stream)) + return; if (check_start_length(count, &start, &length)) return; - STREAM_write(CSTREAM_TO_STREAM(VARG(file)), get_data(THIS, start), length * THIS->size); + STREAM_write(CSTREAM_TO_STREAM(stream), get_data(THIS, start), length * THIS->size); END_METHOD