fix segfault in SQLGetTypeInfo due pyodbc

dont access pages in mdb_fetch_row when pdata is not initialized.

Happens when a client, e.g. pyodbc, queries for an unsupported type,
e.g. SQL_WVARCHAR, temp_table is empty and further access to it will crash.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff70fe3df in mdb_fetch_row (table=0xa74610) at data.c:467
467				rows = mdb_get_int16(

Backtrace:
0  0x00007ffff70fe3df in mdb_fetch_row (table=0xa74610) at data.c:467
1  0x00007ffff77f8746 in SQLFetch (hstmt=0xa70500) at odbc.c:1074
2  0x00007ffff7729b43 in SQLFetch () from /lib/x86_64-linux-gnu/libodbc.so.2
3  0x00007ffff778d545 in GetColumnSize (cnxn=0x7ffff77eb1f0, cnxn=0x7ffff77eb1f0, psize=0x7ffff77bde00, sqltype=-9) at src/cnxninfo.cpp:81
4  CnxnInfo_New (cnxn=0x7ffff77eb1f0) at src/cnxninfo.cpp:145

Signed-off-by: Ulrich Weber <ulrich.weber@gmail.com>
This commit is contained in:
Ulrich Weber 2021-03-24 09:44:46 +00:00
parent e1a850d1a7
commit 970023c4e6

View File

@ -464,6 +464,8 @@ mdb_fetch_row(MdbTableDef *table)
do {
if (table->is_temp_table) {
GPtrArray *pages = table->temp_table_pages;
if (pages->len == 0)
return 0;
rows = mdb_get_int16(
g_ptr_array_index(pages, table->cur_pg_num-1),
fmt->row_count_offset);