From b72ac6b1c060e11bb639ffd1df40e47b6c8e8131 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 19 Aug 2020 10:40:18 +1000 Subject: [PATCH 1/2] Don't crash when a table can't be read for some reason --- src/odbc/odbc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index e2b06a1..568b935 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -1337,6 +1337,11 @@ SQLRETURN SQL_API SQLColumns( if (g_ascii_strcasecmp((char*)szTableName, entry->object_name) != 0) continue; table = mdb_read_table(entry); + if ( !table ) + { + LogError ("Could not read table '%s'", szTableName); + return SQL_ERROR; + } mdb_read_columns(table); for (j=0; jnum_cols; j++) { col = g_ptr_array_index(table->columns, j); From 40981d2fc63d2507a4c882b6be03a7f028e3cf5f Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 19 Aug 2020 10:50:12 +1000 Subject: [PATCH 2/2] Only handle tables in SQLColumns, not other objects --- src/odbc/odbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index 568b935..3359d11 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -1334,7 +1334,7 @@ SQLRETURN SQL_API SQLColumns( for (i=0; inum_catalog; i++) { entry = g_ptr_array_index(mdb->catalog, i); /* TODO: Do more advanced matching */ - if (g_ascii_strcasecmp((char*)szTableName, entry->object_name) != 0) + if (entry->object_type != MDB_TABLE || g_ascii_strcasecmp((char*)szTableName, entry->object_name) != 0) continue; table = mdb_read_table(entry); if ( !table )