diff -ur mysql-5.5.18.orig/sql-common/client.c mysql-5.5.18/sql-common/client.c --- mysql-5.5.18.orig/sql-common/client.c 2011-11-21 18:06:36.895327989 +0100 +++ mysql-5.5.18/sql-common/client.c 2011-11-22 09:56:59.952963401 +0100 @@ -3666,10 +3666,10 @@ static void mysql_prune_stmt_list(MYSQL *mysql) { LIST *element= mysql->stmts; - LIST *pruned_list= 0; - for (; element; element= element->next) + while (element) { + LIST *next= element->next; MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; if (stmt->state != MYSQL_STMT_INIT_DONE) { @@ -3677,14 +3677,10 @@ stmt->last_errno= CR_SERVER_LOST; strmov(stmt->last_error, ER(CR_SERVER_LOST)); strmov(stmt->sqlstate, unknown_sqlstate); + mysql->stmts= list_delete(mysql->stmts, element); } - else - { - pruned_list= list_add(pruned_list, element); - } + element= next; } - - mysql->stmts= pruned_list; }