# HG changeset patch # User nrich@ii.net # Date 1227919874 0 # Node ID 4480ae002881f37f85511bd4026285173ee8e370 # Parent 22046b9961504051aa0aa800eff4c2a25ca36ee9 Bugfix - the size of strings for bind params pointed to the same memory diff -r 22046b996150 -r 4480ae002881 dbd/mysql/statement.c --- a/dbd/mysql/statement.c Fri Nov 28 22:32:14 2008 +0000 +++ b/dbd/mysql/statement.c Sat Nov 29 00:51:14 2008 +0000 @@ -88,7 +88,7 @@ int i = p - 2; const char *str = NULL; - size_t str_len; + size_t *str_len = NULL; double *num = NULL; switch(type) { @@ -112,12 +112,13 @@ break; case LUA_TSTRING: - str = luaL_checklstring(L, p, &str_len); + str_len = malloc(sizeof(size_t)); + str = luaL_checklstring(L, p, str_len); bind[i].buffer_type = MYSQL_TYPE_STRING; bind[i].is_null = (my_bool*)0; bind[i].buffer = (char *)str; - bind[i].length = &str_len; + bind[i].length = str_len; break; default: @@ -145,13 +146,17 @@ for (i = 0; i < num_bind_params; i++) { /* * Free the memory associated with - * the allocation of double bind - * params. If the interface is + * the allocation of double and string + * bind params. If the interface are * 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); + if (bind[i].buffer_type == MYSQL_TYPE_DOUBLE) { + if (bind[i].buffer) + free(bind[i].buffer); + } else if (bind[i].buffer_type == MYSQL_TYPE_STRING) { + if (bind[i].length) + free(bind[i].length); } }