Skip to content

Commit 33116e2

Browse files
committed
[0DBC-110] Fix and testcase of the crash in case of columns unbinding after stmt execution and before fetching data.
The reason was free-ing of 2 internal arrays, that are allocated during execution, and reset at each fetch. SQLFreeStmt(SQL_UNBIND) just shouldn't free them.
1 parent 064a189 commit 33116e2

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

ma_statement.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ SQLRETURN MADB_StmtFree(MADB_Stmt *Stmt, SQLUSMALLINT Option)
206206
break;
207207
case SQL_UNBIND:
208208
MADB_FREE(Stmt->result);
209-
MADB_FREE(Stmt->CharOffset);
210-
MADB_FREE(Stmt->Lengths);
211209
ResetMetadata(&Stmt->metadata);
212210
MADB_DescFree(Stmt->Ard, TRUE);
213211
ResetMetadata(&Stmt->DefaultsResult);

ma_string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ int InitClientCharset(Client_Charset *cc, const char * name)
447447
return 1;
448448
}
449449

450-
cc->CodePage= cc->cs_info->codepage;/*madb_get_windows_cp(name);*/
450+
cc->CodePage= cc->cs_info->codepage;
451451

452452
return 0;
453453
}

test/scroll.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
3-
2013 MontyProgram AB
3+
2013, 2017 MariaDB Corporation AB
44
55
The MySQL Connector/ODBC is licensed under the terms of the GPLv2
66
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -1212,6 +1212,27 @@ ODBC_TEST(t_absolute_2)
12121212
return OK;
12131213
}
12141214

1215+
/*{{{ t_unbind_before_fetch */
1216+
/**
1217+
ODBC-110: Unbinding columns before fetching new result causes crash in the connector whilie fetching the row
1218+
Crash would occur also if ordinary SQLFetch was used. But it had been SQLFetchScroll, when the bug was observed for the 1st time
1219+
Affectts Microsoft ODBC test tool
1220+
*/
1221+
ODBC_TEST(t_unbind_before_fetch)
1222+
{
1223+
SQLUINTEGER dummy;
1224+
1225+
OK_SIMPLE_STMT(Stmt, "SELECT 1");
1226+
1227+
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_UNBIND));
1228+
1229+
CHECK_STMT_RC(Stmt, SQLBindCol(Stmt, 1, SQL_C_ULONG, &dummy, 0, NULL));
1230+
1231+
CHECK_STMT_RC(Stmt, SQLFetchScroll(Stmt, SQL_FETCH_NEXT, 1));
1232+
1233+
return OK;
1234+
}
1235+
/*}}}*/
12151236

12161237
MA_ODBC_TESTS my_tests[]=
12171238
{
@@ -1221,6 +1242,7 @@ MA_ODBC_TESTS my_tests[]=
12211242
{t_array_relative_2, "t_array_relative_2"},
12221243
{t_absolute_1,"t_absolute_1"},
12231244
{t_absolute_2, "t_absolute_2"},
1245+
{t_unbind_before_fetch, "t_odbc_110_unbind_before_fetch"},
12241246
{NULL, NULL}
12251247
};
12261248

0 commit comments

Comments
 (0)