Memory leak in Microsoft ODBC Driver 17.10.5 for SQL Server #1488
Open
Description
This is a report regarding a bug in the odbc driver. I'm writing here because I don't know the appropriate place to report it.
(I also posted it here. https://learn.microsoft.com/en-us/answers/questions/1418766/memory-leak-in-microsoft-odbc-driver-17-10-5-for-s)
The following code:
// odbc.c
#include <sql.h>
#include <sqlext.h>
#include <string.h>
int main(void) {
HENV env;
HDBC db;
char *dsn = "Driver={ODBC Driver 17 for SQL Server};Server=sql-server;Port=1433;Database=test;uid=SA;pwd={/* pass */};"; // myenv
SQLCHAR dsnbuf[1024];
short dsnbuflen;
SQLAllocEnv(&env);
SQLAllocConnect(env, &db);
SQLDriverConnect(db, NULL, (SQLCHAR*) dsn, strlen(dsn), dsnbuf, sizeof(dsnbuf) - 1, &dsnbuflen, SQL_DRIVER_NOPROMPT);
SQLDisconnect(db);
SQLFreeHandle(SQL_HANDLE_DBC, db);
db = NULL;
SQLFreeHandle(SQL_HANDLE_ENV, env);
env = NULL;
SQLAllocEnv(&env);
SQLAllocConnect(env, &db);
SQLDriverConnect(db, NULL, (SQLCHAR*) dsn, strlen(dsn), dsnbuf, sizeof(dsnbuf) - 1, &dsnbuflen, SQL_DRIVER_NOPROMPT);
return 0;
}
compile command:
gcc -fsanitize=leak,undefined,address -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC -Wall -o odbc odbc.c -lodbc
exec:
# ./odbc
=================================================================
==12092==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fd55793e587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
#1 0x7fd5532728da (/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.10.so.5.1+0x1808da)
Indirect leak of 88 byte(s) in 1 object(s) allocated from:
#0 0x7fd55793e587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
#1 0x7fd5531fa909 (/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.10.so.5.1+0x108909)
SUMMARY: AddressSanitizer: 112 byte(s) leaked in 2 allocation(s).
In this way, once I close the connection and connect it again, I will get a memory leak.
Regards.
Metadata
Assignees
Labels
No labels