summaryrefslogtreecommitdiff
path: root/serialize.c
diff options
context:
space:
mode:
Diffstat (limited to 'serialize.c')
-rw-r--r--serialize.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/serialize.c b/serialize.c
index a59151f..8c547ba 100644
--- a/serialize.c
+++ b/serialize.c
@@ -205,12 +205,15 @@ void load_buffer32(deserialize_buffer *buf, uint32_t *dst, size_t len)
}
}
-void load_section(deserialize_buffer *buf)
+int load_section(deserialize_buffer *buf)
{
if (!buf->handlers) {
fatal_error("load_section called on a deserialize_buffer with no handlers registered\n");
}
uint16_t section_id = load_int16(buf);
+ if (section_id == SECTION_END_OF_SERIALIZATION) {
+ return 0;
+ }
uint32_t size = load_int32(buf);
if (size > (buf->size - buf->cur_pos)) {
fatal_error("Section is bigger than remaining space in file");
@@ -218,12 +221,13 @@ void load_section(deserialize_buffer *buf)
if (section_id > buf->max_handler || !buf->handlers[section_id].fun) {
warning("No handler for section ID %d, save state may be from a newer version\n", section_id);
buf->cur_pos += size;
- return;
+ return 1;
}
deserialize_buffer section;
init_deserialize(&section, buf->data + buf->cur_pos, size);
buf->handlers[section_id].fun(&section, buf->handlers[section_id].data);
buf->cur_pos += size;
+ return 1;
}
static const char sz_ident[] = "BLSTSZ\x01\x07";