From c0d989bb490e7106a9dfe31bfe2a1ac9f03ceab4 Mon Sep 17 00:00:00 2001 From: Lawrin Novitsky Date: Fri, 28 Apr 2023 12:34:59 +0200 Subject: [PATCH] ODBC-390 Using SQL_ATTR_QUERY_TIMEOUT leaks memory The string with new query text in MADB_AddQueryTime was allocated and then duplicated, when copied to the Stmt structures, but not freed. --- ma_statement.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ma_statement.c b/ma_statement.c index e2f4e814..3741ed46 100644 --- a/ma_statement.c +++ b/ma_statement.c @@ -662,7 +662,8 @@ void MADB_AddQueryTime(MADB_QUERY* Query, unsigned long long Timeout) Query->Length= _snprintf(NewStr, NewSize, "SET STATEMENT max_statement_time=%llu FOR %s", Timeout, Query->Original); - MADB_RESET(Query->Original, NewStr); + MADB_FREE(Query->Original); + Query->Original= NewStr; } /* {{{ MADB_StmtPrepare */