diff --git a/include/MySQL_PreparedStatement.h b/include/MySQL_PreparedStatement.h index a240cf7ed..0987721bf 100644 --- a/include/MySQL_PreparedStatement.h +++ b/include/MySQL_PreparedStatement.h @@ -84,6 +84,8 @@ class stmt_execute_metadata_t { unsigned long *lengths; void *pkt; stmt_execute_metadata_t() { + size = 0; + stmt_id = 0; binds=NULL; is_nulls=NULL; lengths=NULL; @@ -92,10 +94,15 @@ class stmt_execute_metadata_t { ~stmt_execute_metadata_t() { if (binds) free(binds); + binds = NULL; if (is_nulls) free(is_nulls); + is_nulls = NULL; if (lengths) free(lengths); + lengths = NULL; + size = 0; + stmt_id = 0; } }; diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 2ff2ea1ba..c5862fb95 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -2226,8 +2226,12 @@ __get_pkts_from_client: uint32_t client_global_id=0; memcpy(&client_global_id,(char *)pkt.ptr+5,sizeof(uint32_t)); // FIXME: no input validation + uint64_t stmt_global_id=0; + stmt_global_id=client_myds->myconn->local_stmts->find_global_stmt_id_from_client(client_global_id); SLDH->reset(client_global_id); - sess_STMTs_meta->erase(client_global_id); + if (stmt_global_id) { + sess_STMTs_meta->erase(stmt_global_id); + } client_myds->myconn->local_stmts->client_close(client_global_id); } l_free(pkt.size,pkt.ptr);