Skip to content

Commit 89ce16d

Browse files
committed
A segfault fixed in the issue msgpack#28
1 parent d5f9995 commit 89ce16d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

msgpack/unpack.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ static inline int template_callback_map_end(unpack_user* u, msgpack_unpack_objec
207207
{
208208
if (u->object_hook) {
209209
PyObject *new_c = PyEval_CallFunction(u->object_hook, "(O)", *c);
210+
if (!new_c)
211+
return -1;
212+
210213
Py_DECREF(*c);
211214
*c = new_c;
212215
}

msgpack/unpack_template.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
361361
if(construct_cb(_map_item)(user, c->count, &c->obj, c->map_key, obj) < 0) { goto _failed; }
362362
if(++c->count == c->size) {
363363
obj = c->obj;
364-
construct_cb(_map_end)(user, &obj);
364+
if (construct_cb(_map_end)(user, &obj) < 0) { goto _failed; }
365365
--top;
366366
/*printf("stack pop %d\n", top);*/
367367
goto _push;

0 commit comments

Comments
 (0)