aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/reader.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/reader.h b/src/reader.h
index d9391ac8..252733cf 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -169,14 +169,14 @@ push_bytes(SerdReader* reader,
const uint8_t* bytes,
unsigned len)
{
- if (reader->stack.buf_size < reader->stack.size + len) {
- return SERD_ERR_OVERFLOW;
+ const bool has_space = reader->stack.buf_size >= reader->stack.size + len;
+ if (has_space) {
+ for (unsigned i = 0; i < len; ++i) {
+ push_byte(reader, ref, bytes[i]);
+ }
}
- for (unsigned i = 0; i < len; ++i) {
- push_byte(reader, ref, bytes[i]);
- }
- return SERD_SUCCESS;
+ return has_space ? SERD_SUCCESS : SERD_ERR_OVERFLOW;
}
#endif // SERD_READER_H