aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--src/byte_source.c9
-rw-r--r--test/test_reader_writer.c2
3 files changed, 11 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 4b72e0a6..34e7f83f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,10 @@
serd (0.30.17) unstable; urgency=medium
+ * Fix crash when trying to read chunks without starting
* Override pkg-config dependency within meson
* Test header for warnings more strictly
- -- David Robillard <d@drobilla.net> Sat, 01 Oct 2022 16:24:20 +0000
+ -- David Robillard <d@drobilla.net> Mon, 24 Oct 2022 02:07:19 +0000
serd (0.30.16) stable; urgency=medium
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;
}
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 0ac589f1..52d78e29 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -290,6 +290,8 @@ test_reader(const char* path)
assert(reader);
assert(serd_reader_get_handle(reader) == rt);
+ assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
+
SerdNode g = serd_node_from_string(SERD_URI, USTR("http://example.org/"));
serd_reader_set_default_graph(reader, &g);
serd_reader_add_blank_prefix(reader, USTR("tmp"));