From df9078ea55e2bd60d718c6e6948b70311650fe39 Mon Sep 17 00:00:00 2001 From: Keyur Govande Date: Tue, 7 Oct 2014 21:17:36 +0000 Subject: Fix for bug #68087 (ODBC not reading DATE columns correctly) Temporary variable indicating column field type ID should be reset to default for loop iteration (i.e. every column in the record set. The old buggy code made it persist across all columns leading to invalid reads from the buffer, if for example a DATE column was preceded by a VARCHAR column. --- ext/odbc/php_odbc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ext/odbc/php_odbc.c') diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 19f9fe4eb0..b9bee9676a 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -951,14 +951,15 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC) SQLUSMALLINT colfieldid; int charextraalloc; - colfieldid = SQL_COLUMN_DISPLAY_SIZE; - charextraalloc = 0; result->values = (odbc_result_value *) safe_emalloc(sizeof(odbc_result_value), result->numcols, 0); result->longreadlen = ODBCG(defaultlrl); result->binmode = ODBCG(defaultbinmode); for(i = 0; i < result->numcols; i++) { + charextraalloc = 0; + colfieldid = SQL_COLUMN_DISPLAY_SIZE; + rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_NAME, result->values[i].name, sizeof(result->values[i].name), &colnamelen, 0); rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_TYPE, -- cgit v1.2.1