From 60bb5a65ae961ae8cddfead620193ac390a05b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Thu, 18 Mar 2021 16:19:52 +0000 Subject: [PATCH] Closes #3350: Free memory when allocated for specific 'stmt_execute_metadata_t' bind buffers types --- lib/MySQL_Session.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index fad92a13a..d079cf48b 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -3885,6 +3885,21 @@ void MySQL_Session::handler_rc0_PROCESSING_STMT_EXECUTE(MySQL_Data_Stream *myds) free(CurrentQuery.stmt_meta->pkt); CurrentQuery.stmt_meta->pkt=NULL; } + + // free for all the buffer types in which we allocate + for (int i = 0; i < CurrentQuery.stmt_meta->num_params; i++) { + enum enum_field_types buffer_type = + CurrentQuery.stmt_meta->binds[i].buffer_type; + + if ( + (buffer_type == MYSQL_TYPE_TIME) || + (buffer_type == MYSQL_TYPE_DATE) || + (buffer_type == MYSQL_TYPE_TIMESTAMP) || + (buffer_type == MYSQL_TYPE_DATETIME) + ) { + free(CurrentQuery.stmt_meta->binds[i].buffer); + } + } } CurrentQuery.mysql_stmt=NULL; }