aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-12-08 23:21:23 +0100
committerDavid Robillard <d@drobilla.net>2019-12-08 23:21:23 +0100
commit2efb107eb4d4381198de51bd4f092ae1ead02e31 (patch)
treeee89c919e80d041d6eae2b08abfd247c2fc67be2 /src
parent41a5903cc5350b9e90ebfbeea66a3a1eabe7f663 (diff)
downloadserd-2efb107eb4d4381198de51bd4f092ae1ead02e31.tar.gz
serd-2efb107eb4d4381198de51bd4f092ae1ead02e31.tar.bz2
serd-2efb107eb4d4381198de51bd4f092ae1ead02e31.zip
Fix reading from a null-delimited socket
Diffstat (limited to 'src')
-rw-r--r--src/reader.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/reader.c b/src/reader.c
index 68a5f886..ef393ec7 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -14,6 +14,7 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include "reader.h"
#include "serd_internal.h"
#include <ctype.h>
@@ -343,6 +344,11 @@ serd_reader_read_chunk(SerdReader* reader)
st = serd_byte_source_advance(&reader->source);
}
+ if (peek_byte(reader) == 0) {
+ // Skip leading null byte, for reading from a null-delimited socket
+ eat_byte_safe(reader, 0);
+ }
+
return st ? st : read_statement(reader) ? SERD_SUCCESS : SERD_FAILURE;
}