summaryrefslogtreecommitdiff
path: root/toxcore/util.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2015-07-17 22:51:14 -0400
committerirungentoo <irungentoo@gmail.com>2015-07-17 22:51:14 -0400
commitdb88dc7b4525b4ea2eb11f4c4df85bf132cd0c74 (patch)
treea7816a824aeeaed48b407db68e55b9b6779cac1c /toxcore/util.c
parent6ecf2941ac71e36d6978539b0dd24b7ad1ecf8f1 (diff)
Allow savedata to be slightly smaller than the allocated buffer.
Diffstat (limited to 'toxcore/util.c')
-rw-r--r--toxcore/util.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/toxcore/util.c b/toxcore/util.c
index 5a72c4a4..5caf5855 100644
--- a/toxcore/util.c
+++ b/toxcore/util.c
@@ -153,8 +153,15 @@ int load_state(load_state_callback_func load_state_callback, void *outer,
153 153
154 type = lendian_to_host16(cookie_type & 0xFFFF); 154 type = lendian_to_host16(cookie_type & 0xFFFF);
155 155
156 if (-1 == load_state_callback(outer, data, length_sub, type)) 156 int ret = load_state_callback(outer, data, length_sub, type);
157
158 if (ret == -1) {
157 return -1; 159 return -1;
160 }
161
162 /* -2 means end of save. */
163 if (ret == -2)
164 return 0;
158 165
159 data += length_sub; 166 data += length_sub;
160 length -= length_sub; 167 length -= length_sub;