# HG changeset patch # User Matthew Wild # Date 1341009439 -7200 # Node ID 5ba1dd988961b6961dccd3aeb36d26b812e225c1 # Parent 7c968f66bccdf963ce9f7504ef2badcc265bb36d MySQL: Fix off-by-one in allocation and pass address of correct bind result buffer to mysql_stmt_fetch_column() diff -r 7c968f66bccd -r 5ba1dd988961 dbd/mysql/statement.c --- a/dbd/mysql/statement.c Fri Jun 29 17:45:37 2012 +0100 +++ b/dbd/mysql/statement.c Sat Jun 30 00:37:19 2012 +0200 @@ -346,12 +346,10 @@ const char *name = fields[i].name; if (bind[i].buffer == NULL) { - char *buffer = (char *)malloc(real_length[i]); - memset(buffer, 0, real_length[i]); - + char *buffer = (char *)calloc(real_length[i]+1, sizeof(char)); bind[i].buffer = buffer; bind[i].buffer_length = real_length[i]; - mysql_stmt_fetch_column(statement->stmt, bind, i, 0); + mysql_stmt_fetch_column(statement->stmt, &bind[i], i, 0); } if (lua_push == LUA_PUSH_NIL) {