git » libjio » commit 5610990

bindings/python: Use ssize_t for s# parameters

author Alberto Bertogli
2010-04-04 05:41:42 UTC
committer Alberto Bertogli
2010-04-04 05:48:13 UTC
parent 1ee54b0c2e244ddcba943208bb19ddb66ece2b60

bindings/python: Use ssize_t for s# parameters

Commit 9607741 (bindings/python: Add readv()/writev() support, 2009-07-13)
defined PY_SSIZE_T_CLEAN, which made PyArg_ParseTuple()'s s# parameters use
ssize_t for the string length, instead of int (which is the default). That was
needed for writev().

However, existing instances of s# were not converted, and caused subtle but
worrying memory corruption.

This patch fixes that by using ssize_t in the appropriate places.

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

bindings/python/libjio.c +3 -3

diff --git a/bindings/python/libjio.c b/bindings/python/libjio.c
index 46b257d..b75ba98 100644
--- a/bindings/python/libjio.c
+++ b/bindings/python/libjio.c
@@ -279,7 +279,7 @@ static PyObject *jf_write(jfile_object *fp, PyObject *args)
 {
 	long rv;
 	unsigned char *buf;
-	int len;
+	ssize_t len;
 
 	if (!PyArg_ParseTuple(args, "s#:write", &buf, &len))
 		return NULL;
@@ -307,7 +307,7 @@ static PyObject *jf_pwrite(jfile_object *fp, PyObject *args)
 	long rv;
 	unsigned char *buf;
 	long long offset;
-	int len;
+	ssize_t len;
 
 	if (!PyArg_ParseTuple(args, "s#L:pwrite", &buf, &len, &offset))
 		return NULL;
@@ -659,7 +659,7 @@ It's a wrapper to jtrans_add_w().\n");
 static PyObject *jt_add_w(jtrans_object *tp, PyObject *args)
 {
 	long rv;
-	int len;
+	ssize_t len;
 	long long offset;
 	unsigned char *buf;