Message-ID: From: "davecramer (@davecramer)" To: "postgresql-interfaces/psqlodbc" Date: Fri, 22 May 2026 14:06:21 +0000 Subject: [postgresql-interfaces/psqlodbc] PR #190: Fix double-free / heap corruption during SQLDisconnect cleanup (#189) List-Id: X-GitHub-Author-Id: 406518 X-GitHub-Author-Login: davecramer X-GitHub-Issue: 190 X-GitHub-Repo: postgresql-interfaces/psqlodbc X-GitHub-State: merged X-GitHub-Type: pull_request X-GitHub-Url: https://github.com/postgresql-interfaces/psqlodbc/pull/190 Content-Type: text/plain; charset=utf-8 CC_cleanup() was freeing statement and descriptor objects via SC_Destructor(), but the ODBC Driver Manager still held handles to them. When the DM later called SQLFreeStmt(SQL_DROP) via SQLFreeHandle(), the driver dereferenced freed memory, causing the double-free detected by Application Verifier with Page Heap enabled. Fix by detaching statements/descriptors in CC_cleanup() without freeing them. The DM will free them later through the normal SQLFreeHandle path. Also allow SQLFreeStmt(SQL_DROP) to proceed when hdbc is NULL (the expected state after disconnect), and remove misleading error-return logic in SC_Destructor that reported failure after already freeing.