Skip to content

Commit

Permalink
fix double lock
Browse files Browse the repository at this point in the history
found by coverity

 754
       2. lock: SQLFetch locks hStmt->mutex.[show details]
       3. Condition (ret = SQLFetch(hStmt)) == 0, taking false branch.
      CID 442426:(lurcher#2 of 4):Double lock (LOCK) [ "select issue" ]
 755    while ( (ret = SQLFetch( hStmt )) == SQL_SUCCESS ) /* ROWS */
  • Loading branch information
chipitsine committed Oct 17, 2024
1 parent 2234e8b commit 3c03a97
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions DriverManager/SQLFetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
}

0 comments on commit 3c03a97

Please sign in to comment.