mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-22 21:33:17 +00:00
Revert skipping reserved byte.
This commit is contained in:
parent
a6859791a2
commit
38a9ad98c9
2 changed files with 44 additions and 50 deletions
|
@ -57,7 +57,6 @@ TYPE_IMMEDIATE = 0
|
||||||
TYPE_ARRAY = 1
|
TYPE_ARRAY = 1
|
||||||
TYPE_MAP = 2
|
TYPE_MAP = 2
|
||||||
TYPE_RAW = 3
|
TYPE_RAW = 3
|
||||||
TYPE_RESERVED = 4
|
|
||||||
|
|
||||||
DEFAULT_RECURSE_LIMIT=511
|
DEFAULT_RECURSE_LIMIT=511
|
||||||
|
|
||||||
|
@ -338,12 +337,10 @@ class Unpacker(object):
|
||||||
n = struct.unpack(">I", self._fb_read(4, write_bytes))[0]
|
n = struct.unpack(">I", self._fb_read(4, write_bytes))[0]
|
||||||
typ = TYPE_MAP
|
typ = TYPE_MAP
|
||||||
else:
|
else:
|
||||||
typ = TYPE_RESERVED
|
raise UnpackValueError("Unknown header: 0x%x" % b)
|
||||||
return typ, n, obj
|
return typ, n, obj
|
||||||
|
|
||||||
def _fb_unpack(self, execute=EX_CONSTRUCT, write_bytes=None):
|
def _fb_unpack(self, execute=EX_CONSTRUCT, write_bytes=None):
|
||||||
typ = TYPE_RESERVED
|
|
||||||
while typ == TYPE_RESERVED:
|
|
||||||
typ, n, obj = self._read_header(execute, write_bytes)
|
typ, n, obj = self._read_header(execute, write_bytes)
|
||||||
|
|
||||||
if execute == EX_READ_ARRAY_HEADER:
|
if execute == EX_READ_ARRAY_HEADER:
|
||||||
|
|
|
@ -422,10 +422,7 @@ _end:
|
||||||
template <unsigned int fixed_offset, unsigned int var_offset>
|
template <unsigned int fixed_offset, unsigned int var_offset>
|
||||||
msgpack_unpack_func(int, _container_header)(msgpack_unpack_struct(_context)* ctx, const char* data, size_t len, size_t* off)
|
msgpack_unpack_func(int, _container_header)(msgpack_unpack_struct(_context)* ctx, const char* data, size_t len, size_t* off)
|
||||||
{
|
{
|
||||||
for (;;) {
|
assert(len >= *off);
|
||||||
if (len < *off) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
const unsigned char *const p = (unsigned char*)data + *off;
|
const unsigned char *const p = (unsigned char*)data + *off;
|
||||||
|
|
||||||
|
@ -467,11 +464,11 @@ msgpack_unpack_func(int, _container_header)(msgpack_unpack_struct(_context)* ctx
|
||||||
size = ((unsigned int)*p) & 0x0f;
|
size = ((unsigned int)*p) & 0x0f;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
PyErr_SetString(PyExc_ValueError, "Unexpected type header on stream");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
msgpack_unpack_callback(_uint32)(&ctx->user, size, &ctx->stack[0].obj);
|
msgpack_unpack_callback(_uint32)(&ctx->user, size, &ctx->stack[0].obj);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef SWITCH_RANGE_BEGIN
|
#undef SWITCH_RANGE_BEGIN
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue