From 3c03a970798c2c531225d945da143488139d65ab Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Thu, 17 Oct 2024 22:19:38 +0200 Subject: [PATCH] fix double lock found by coverity 754 2. lock: SQLFetch locks hStmt->mutex.[show details] 3. Condition (ret = SQLFetch(hStmt)) == 0, taking false branch. CID 442426:(#2 of 4):Double lock (LOCK) [ "select issue" ] 755 while ( (ret = SQLFetch( hStmt )) == SQL_SUCCESS ) /* ROWS */ --- DriverManager/SQLFetch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DriverManager/SQLFetch.c b/DriverManager/SQLFetch.c index 531d09e..a24cd01 100644 --- a/DriverManager/SQLFetch.c +++ b/DriverManager/SQLFetch.c @@ -169,8 +169,6 @@ SQLRETURN SQLFetch( SQLHSTMT statement_handle ) * check states */ - thread_protect( SQL_HANDLE_STMT, statement ); - if ( statement -> state == STATE_S1 || statement -> state == STATE_S2 || statement -> state == STATE_S3 ) @@ -326,6 +324,8 @@ SQLRETURN SQLFetch( SQLHSTMT statement_handle ) return function_return_nodrv( SQL_HANDLE_STMT, statement, SQL_ERROR ); } + thread_protect( SQL_HANDLE_STMT, statement ); + if ( ret == SQL_STILL_EXECUTING ) { statement -> interupted_func = SQL_API_SQLFETCH; @@ -355,5 +355,6 @@ SQLRETURN SQLFetch( SQLHSTMT statement_handle ) statement -> msg ); } + thread_release( SQL_HANDLE_STMT, statement ); return function_return( SQL_HANDLE_STMT, statement, ret, DEFER_R3 ); }