git » libjio » commit 251fcad

bindings/python: Fix broken realloc() new size

author Alberto Bertogli
2011-02-27 11:39:53 UTC
committer Alberto Bertogli
2011-02-27 21:23:34 UTC
parent 036fe769755f430dac1d4be7effaa107614145da

bindings/python: Fix broken realloc() new size

This patch fixes the new size parameter given to realloc(), which was (very)
wrong.

Surprisingly, this simple mistake wasn't caught by the tests OR valgrind under
Linux, but on FreeBSD made one of the tests crash (behaviour n23), and it did
appear under valgrind on that platform.

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

bindings/python/libjio.c +1 -1

diff --git a/bindings/python/libjio.c b/bindings/python/libjio.c
index c37ec86..f033dfb 100644
--- a/bindings/python/libjio.c
+++ b/bindings/python/libjio.c
@@ -771,7 +771,7 @@ static PyObject *jt_add_r(jtrans_object *tp, PyObject *args)
 		return PyErr_SetFromErrno(PyExc_IOError);
 	}
 
-	new_views = realloc(tp->views, sizeof(Py_buffer *) * tp->nviews + 1);
+	new_views = realloc(tp->views, sizeof(Py_buffer *) * (tp->nviews + 1));
 	if (new_views == NULL) {
 		PyBuffer_Release(view);
 		free(view);