The parameter 'offset' of unpack() function family, not unpacker family, updates only when the function successfully finished.

The parameter 'offset' used to update even if a caller passes insufficient bytes to the unpack() function family.
This commit is contained in:
Takatoshi Kondo
2015-08-19 10:52:08 +09:00
parent 294aa52c3a
commit 92822996e2
4 changed files with 91 additions and 4 deletions

View File

@@ -618,12 +618,13 @@ msgpack_unpack_next(msgpack_unpacked* result,
return MSGPACK_UNPACK_PARSE_ERROR;
}
if(off != NULL) { *off = noff; }
if(e == 0) {
return MSGPACK_UNPACK_CONTINUE;
}
if(off != NULL) { *off = noff; }
result->data = template_data(&ctx);
return MSGPACK_UNPACK_SUCCESS;