summaryrefslogtreecommitdiff
path: root/src/pooptmodule.c
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-06-07 00:04:01 +0200
committerFlorent Le Coz <louiz@louiz.org>2013-06-07 00:04:01 +0200
commit463ec5ca0d904f62afac9ef5c6c146d9490103c5 (patch)
tree29e4a52f53f79690a14619703a3156424efebd89 /src/pooptmodule.c
parent4b537d3477bf48ade8d8de5dca15101d0427f1be (diff)
downloadpoezio-463ec5ca0d904f62afac9ef5c6c146d9490103c5.tar.gz
poezio-463ec5ca0d904f62afac9ef5c6c146d9490103c5.tar.bz2
poezio-463ec5ca0d904f62afac9ef5c6c146d9490103c5.tar.xz
poezio-463ec5ca0d904f62afac9ef5c6c146d9490103c5.zip
Accept NULL bytes in strings to be cut by the poopt module
fix #2296
Diffstat (limited to 'src/pooptmodule.c')
-rw-r--r--src/pooptmodule.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/pooptmodule.c b/src/pooptmodule.c
index 7d40398d..8bf0a22e 100644
--- a/src/pooptmodule.c
+++ b/src/pooptmodule.c
@@ -33,10 +33,11 @@ PyDoc_STRVAR(poopt_cut_text_doc, "cut_text(text, width)\n\n\nReturn a list of tw
static PyObject *poopt_cut_text(PyObject *self, PyObject *args)
{
- unsigned char *buffer;
- int width;
+ const unsigned char *buffer;
+ const int width;
+ const size_t buffer_len;
- if (PyArg_ParseTuple(args, "si", &buffer, &width) == 0)
+ if (PyArg_ParseTuple(args, "is#", &width, &buffer, &buffer_len) == 0)
return NULL;
int bpos = 0; /* the real position in the char* */
@@ -48,7 +49,7 @@ static PyObject *poopt_cut_text(PyObject *self, PyObject *args)
of colors attribute be ignored */
PyObject* retlist = PyList_New(0);
- while (buffer[bpos])
+ while (bpos < buffer_len)
{
if (buffer[bpos] == ' ')
last_space = spos;