Skip to content

Commit

Permalink
odbc: Avoid possible leak detection on driver unload
Browse files Browse the repository at this point in the history
For debug Windows build if the ODBC driver is unloaded a leak
detector is activated.
It looks like from AppVeyor logs that sometimes during the leak
detector some leak are detected.
To avoid these false positive free memory before calling
SQLFreeEnv (which could unload the driver from memory).
Also decrease socket library counter calling WSACleanup().

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
  • Loading branch information
freddy77 committed Feb 5, 2025
1 parent d405d55 commit e3674e5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/odbc/unittests/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ odbc_disconnect(void)
odbc_conn = SQL_NULL_HDBC;
}

ODBC_FREE();
if (odbc_env) {
SQLFreeEnv(odbc_env);
odbc_env = SQL_NULL_HENV;
Expand Down
1 change: 1 addition & 0 deletions win32/initnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved TDS_UNUSED)
break;

case DLL_PROCESS_DETACH:
tds_socket_done();
#if defined(_MSC_VER) && defined(_DEBUG)
_CrtDumpMemoryLeaks();
#endif
Expand Down

0 comments on commit e3674e5

Please sign in to comment.