You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-python/sabyenc/files/sabyenc-4.0.2-fix-segfault....

29 lines
1.1 KiB

From: Arthur Zamarin <arthurzam@gmail.com>
Date: Sat, 18 Sep 2021 21:07:45 +0300
Subject: Fix Segfault during testing
decode_usenet_chunks might receive it argument as bytesarray, or
as bytes object, but the C code expects only bytesarray.
Add code, to apply variant for each case, and fail using assert when
both don't apply.
Signed-off-by: Arthur Zamarin <arthurzam@gmail.com>
--- a/src/sabyenc3.c
+++ b/src/sabyenc3.c
@@ -593,7 +593,13 @@ PyObject* decode_usenet_chunks(PyObject* self, PyObject* args) {
num_bytes_reserved = 0;
lp_max = (int)PyList_Size(Py_input_list);
for(lp = 0; lp < lp_max; lp++) {
- num_bytes_reserved += (int)PyByteArray_GET_SIZE(PyList_GetItem(Py_input_list, lp));
+ PyObject *temp = PyList_GetItem(Py_input_list, lp);
+ if (PyByteArray_Check(temp))
+ num_bytes_reserved += (int)PyByteArray_GET_SIZE(temp);
+ else if (PyBytes_Check(temp))
+ num_bytes_reserved += (int)PyBytes_GET_SIZE(temp);
+ else
+ assert(PyByteArray_Check(temp) || PyBytes_Check(temp));
}
}