From b7e22e9227a83b3c2f925b774f0794084ba526ff Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 23 Oct 2022 22:07:43 -0400 Subject: Fix crash when trying to read chunks without starting --- src/byte_source.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/byte_source.c b/src/byte_source.c index 2450b856..7c191745 100644 --- a/src/byte_source.c +++ b/src/byte_source.c @@ -66,6 +66,10 @@ serd_byte_source_open_source(SerdByteSource* const source, SerdStatus serd_byte_source_prepare(SerdByteSource* const source) { + if (source->page_size == 0) { + return SERD_FAILURE; + } + source->prepared = true; if (source->from_stream) { @@ -83,8 +87,9 @@ serd_byte_source_open_string(SerdByteSource* const source, const Cursor cur = {(const uint8_t*)"(string)", 1, 1}; memset(source, '\0', sizeof(*source)); - source->cur = cur; - source->read_buf = utf8; + source->page_size = 1; + source->cur = cur; + source->read_buf = utf8; return SERD_SUCCESS; } -- cgit v1.2.1