git » libjio » commit c7d31f2

python: Fix int/long argument parsing mismatch

author Alberto Bertogli
2010-05-26 03:22:45 UTC
committer Alberto Bertogli
2010-05-26 03:22:45 UTC
parent ee371c36e6e24e1882f89696a2961af6897e0149

python: Fix int/long argument parsing mismatch

Some PyArg_ParseTuple() invocations were told to parse to an int, but a long
was given to it instead.

On 64-bit platforms that mismatch caused trouble, but luckily nothing that
could cause corruption, since the resulting values were given to malloc(),
which would fail.

This issue came up when running the behaviour tests in Fedora 13.

The patch fixes this by telling PyArg_ParseTuple() we are giving it a long
instead of an int.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

bindings/python/libjio.c +2 -2

diff --git a/bindings/python/libjio.c b/bindings/python/libjio.c
index b75ba98..e0c8c68 100644
--- a/bindings/python/libjio.c
+++ b/bindings/python/libjio.c
@@ -101,7 +101,7 @@ static PyObject *jf_read(jfile_object *fp, PyObject *args)
 	unsigned char *buf;
 	PyObject *r;
 
-	if (!PyArg_ParseTuple(args, "i:read", &len))
+	if (!PyArg_ParseTuple(args, "l:read", &len))
 		return NULL;
 
 	buf = malloc(len);
@@ -142,7 +142,7 @@ static PyObject *jf_pread(jfile_object *fp, PyObject *args)
 	unsigned char *buf;
 	PyObject *r;
 
-	if (!PyArg_ParseTuple(args, "iL:pread", &len, &offset))
+	if (!PyArg_ParseTuple(args, "lL:pread", &len, &offset))
 		return NULL;
 
 	buf = malloc(len);