mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-06-28 03:30:24 +00:00
fix: avoid memory leak when decoding invalid nested arrays (#671)
This commit is contained in:
parent
378edc60f1
commit
4a07745675
3 changed files with 44 additions and 0 deletions
|
|
@ -72,6 +72,14 @@ static inline PyObject* unpack_data(unpack_context* ctx)
|
|||
|
||||
static inline void unpack_clear(unpack_context *ctx)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 1; i < ctx->top; i++) {
|
||||
Py_CLEAR(ctx->stack[i].obj);
|
||||
/* map_key holds a live reference only while waiting for the value */
|
||||
if (ctx->stack[i].ct == CT_MAP_VALUE) {
|
||||
Py_CLEAR(ctx->stack[i].map_key);
|
||||
}
|
||||
}
|
||||
Py_CLEAR(ctx->stack[0].obj);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue