From 1409c8d0da9599eeaf495b08f065ba90017b4c65 Mon Sep 17 00:00:00 2001 From: adustman Date: Sat, 27 Apr 2002 00:12:57 +0000 Subject: [PATCH] Fix memory leak in _mysql_escape_dict. (Danny Yoo) SSCursor.fetchall() (_mysql_ResultObject_fetch_row) didn't properly increase the size of the result tuple if the result set was more than 1000 rows. (Danny Yoo) --- MySQLdb/_mysql.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MySQLdb/_mysql.c b/MySQLdb/_mysql.c index a762ac9..a87de9c 100644 --- a/MySQLdb/_mysql.c +++ b/MySQLdb/_mysql.c @@ -1,4 +1,4 @@ -#define version_info "(0,9,2,'beta',1)" +#define version_info "(0,9,2,'beta',2)" #define __version__ "0.9.2" /* This program is free software; you can redistribute it and/or modify @@ -579,6 +579,7 @@ _mysql_escape_dict( quoted = _escape_item(item, d); if (!quoted) goto error; if (PyDict_SetItem(r, pkey, quoted)==-1) goto error; + Py_DECREF(quoted); } return r; error: @@ -856,6 +857,12 @@ _mysql_ResultObject_fetch_row( if (rowsadded == -1) goto error; skiprows += rowsadded; if (rowsadded < maxrows) break; +#if PY_VERSION_HEX < 0x02020000 + if (_PyTuple_Resize(&r, skiprows+maxrows, 0) == -1) +#else + if (_PyTuple_Resize(&r, skiprows+maxrows) == -1) +#endif + goto error; } } else { /* XXX if overflow, maxrows<0? */