# HG changeset patch # User nrich@ii.net # Date 1227911534 0 # Node ID 22046b9961504051aa0aa800eff4c2a25ca36ee9 # Parent e66b88e013ca3764d935477ca3284bcbad5e37ea Fixed bug: double bind params were using the same variables memory space so they were all being set to the same number. diff -r e66b88e013ca -r 22046b996150 dbd/mysql/statement.c --- a/dbd/mysql/statement.c Wed Nov 26 10:46:42 2008 +0000 +++ b/dbd/mysql/statement.c Fri Nov 28 22:32:14 2008 +0000 @@ -89,8 +89,7 @@ const char *str = NULL; size_t str_len; - - double num; + double *num = NULL; switch(type) { case LUA_TNIL: @@ -99,11 +98,16 @@ break; case LUA_TNUMBER: - num = luaL_checknumber(L, p); + /* + * num needs to be it's own + * memory here + */ + num = (double *)malloc(sizeof(double)); + *num = luaL_checknumber(L, p); bind[i].buffer_type = MYSQL_TYPE_DOUBLE; bind[i].is_null = (my_bool*)0; - bind[i].buffer = (char *)# + bind[i].buffer = (char *)num; bind[i].length = 0; break; @@ -135,8 +139,24 @@ metadata = mysql_stmt_result_metadata(statement->stmt); cleanup: - if (bind) + if (bind) { + int i; + + for (i = 0; i < num_bind_params; i++) { + /* + * Free the memory associated with + * the allocation of double bind + * params. If the interface is + * extended with other types they + * will need to be added here + */ + if (bind[i].buffer_type == MYSQL_TYPE_DOUBLE && bind[i].buffer) { + free(bind[i].buffer); + } + } + free(bind); + } if (error_message) { lua_pushboolean(L, 0);