diff options
Diffstat (limited to 'dev-python/sabyenc/files/sabyenc-4.0.2-fix-segfault.patch')
-rw-r--r-- | dev-python/sabyenc/files/sabyenc-4.0.2-fix-segfault.patch | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/dev-python/sabyenc/files/sabyenc-4.0.2-fix-segfault.patch b/dev-python/sabyenc/files/sabyenc-4.0.2-fix-segfault.patch new file mode 100644 index 000000000000..1a80d5f13da8 --- /dev/null +++ b/dev-python/sabyenc/files/sabyenc-4.0.2-fix-segfault.patch @@ -0,0 +1,28 @@ +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)); + } + } + |