File: mysql-off-by-one.patch

package info (click to toggle)
lua-dbi 0.5%2Bsvn78-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 360 kB
  • sloc: ansic: 2,908; makefile: 77
file content (23 lines) | stat: -rw-r--r-- 692 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

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) {