From 1184d41881c9c459698a0793b19406b17bb142a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sat, 18 Mar 2017 12:14:01 +0000 Subject: [PATCH] [INTERPRETER] * BUG: Fix a possible bad serialization of arrays. * BUG: Don't crash during the unserialisation of an array whose datatype has been incorrectly serialized. Raise an error instead. git-svn-id: svn://localhost/gambas/trunk@8110 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/gbx/gbx_stream.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main/gbx/gbx_stream.c b/main/gbx/gbx_stream.c index 8a358bcb4..4701d8a99 100644 --- a/main/gbx/gbx_stream.c +++ b/main/gbx/gbx_stream.c @@ -1050,6 +1050,8 @@ void STREAM_read_type(STREAM *stream, TYPE type, VALUE *value) STREAM_read(stream, &buffer._byte, 1); type = (TYPE)buffer._byte; + if (type > T_OBJECT) + THROW(E_SERIAL); size = read_length(stream); @@ -1392,8 +1394,12 @@ void STREAM_write_type(STREAM *stream, TYPE type, VALUE *value) { buffer._byte = 'A'; STREAM_write(stream, &buffer._byte, 1); - - buffer._byte = (unsigned char)Min(T_OBJECT, array->type); + + if (TYPE_is_object(array->type)) + buffer._byte = T_OBJECT; + else + buffer._byte = (unsigned char)array->type; + STREAM_write(stream, &buffer._byte, 1); write_length(stream, array->count);