Skip to content

Commit 1107f47

Browse files
committed
Build tuple directly rather than using Py_BuildValue
1 parent 1509a7a commit 1107f47

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/isal/isal_zlibmodule.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,16 +426,19 @@ ParallelCompress_compress_and_crc(ParallelCompress *self, PyObject *args)
426426
self->zst.avail_in);
427427
goto error;
428428
}
429+
PyObject *out_tup = PyTuple_New(2);
430+
PyObject *crc_obj = PyLong_FromUnsignedLong(self->zst.internal_state.crc);
429431
PyObject *out_bytes = PyBytes_FromStringAndSize(
430432
(char *)self->buffer, self->zst.next_out - self->buffer);
431-
if (out_bytes == NULL) {
433+
if (out_bytes == NULL || out_tup == NULL || crc_obj == NULL) {
434+
Py_XDECREF(out_bytes); Py_XDECREF(out_tup); Py_XDECREF(crc_obj);
432435
goto error;
433436
}
434437
PyBuffer_Release(&data);
435438
PyBuffer_Release(&zdict);
436-
PyObject *ret= Py_BuildValue("(OI)", out_bytes, self->zst.internal_state.crc);
437-
Py_DECREF(out_bytes);
438-
return ret;
439+
PyTuple_SET_ITEM(out_tup, 0, out_bytes);
440+
PyTuple_SET_ITEM(out_tup, 1, crc_obj);
441+
return out_tup;
439442
error:
440443
PyBuffer_Release(&data);
441444
PyBuffer_Release(&zdict);

0 commit comments

Comments
 (0)