Skip to content

Commit 95c8be5

Browse files
fix: check return code in unpack_callback_int64 (#665)
1 parent 5d465bd commit 95c8be5

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

msgpack/unpack.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,7 @@ static inline int unpack_callback_uint32(unpack_user* u, uint32_t d, msgpack_unp
7070

7171
static inline int unpack_callback_uint64(unpack_user* u, uint64_t d, msgpack_unpack_object* o)
7272
{
73-
PyObject *p;
74-
if (d > LONG_MAX) {
75-
p = PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)d);
76-
} else {
77-
p = PyLong_FromLong((long)d);
78-
}
73+
PyObject *p = PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)d);
7974
if (!p)
8075
return -1;
8176
*o = p;
@@ -103,12 +98,9 @@ static inline int unpack_callback_int8(unpack_user* u, int8_t d, msgpack_unpack_
10398

10499
static inline int unpack_callback_int64(unpack_user* u, int64_t d, msgpack_unpack_object* o)
105100
{
106-
PyObject *p;
107-
if (d > LONG_MAX || d < LONG_MIN) {
108-
p = PyLong_FromLongLong((PY_LONG_LONG)d);
109-
} else {
110-
p = PyLong_FromLong((long)d);
111-
}
101+
PyObject *p = PyLong_FromLongLong((PY_LONG_LONG)d);
102+
if (!p)
103+
return -1;
112104
*o = p;
113105
return 0;
114106
}

0 commit comments

Comments
 (0)