aboutsummaryrefslogtreecommitdiffstats
path: root/src/byte_source.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-10-23 22:07:43 -0400
committerDavid Robillard <d@drobilla.net>2022-10-23 22:07:43 -0400
commitb7e22e9227a83b3c2f925b774f0794084ba526ff (patch)
tree2318533e46082bb5911806a9012a4cb20062de32 /src/byte_source.c
parentd03269378d797ea1f721c102eac39df74e559add (diff)
downloadserd-b7e22e9227a83b3c2f925b774f0794084ba526ff.tar.gz
serd-b7e22e9227a83b3c2f925b774f0794084ba526ff.tar.bz2
serd-b7e22e9227a83b3c2f925b774f0794084ba526ff.zip
Fix crash when trying to read chunks without starting
Diffstat (limited to 'src/byte_source.c')
-rw-r--r--src/byte_source.c9
1 files changed, 7 insertions, 2 deletions
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;
}