diff options
author | David Robillard <d@drobilla.net> | 2022-10-23 22:07:43 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-10-23 22:07:43 -0400 |
commit | b7e22e9227a83b3c2f925b774f0794084ba526ff (patch) | |
tree | 2318533e46082bb5911806a9012a4cb20062de32 | |
parent | d03269378d797ea1f721c102eac39df74e559add (diff) | |
download | serd-b7e22e9227a83b3c2f925b774f0794084ba526ff.tar.gz serd-b7e22e9227a83b3c2f925b774f0794084ba526ff.tar.bz2 serd-b7e22e9227a83b3c2f925b774f0794084ba526ff.zip |
Fix crash when trying to read chunks without starting
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/byte_source.c | 9 | ||||
-rw-r--r-- | test/test_reader_writer.c | 2 |
3 files changed, 11 insertions, 3 deletions
@@ -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")); |