aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/reader.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/reader.h b/src/reader.h
index bded249a..3f830ef4 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -167,14 +167,14 @@ push_bytes(SerdReader* reader,
const uint8_t* bytes,
unsigned len)
{
- if (reader->stack.buf_size < reader->stack.size + len) {
- return SERD_BAD_STACK;
+ 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_BAD_STACK;
}
#endif // SERD_SRC_READER_H