]> granicus.if.org Git - php/commitdiff
ensure that this size is initialized correctly
authorWez Furlong <wez@php.net>
Mon, 26 Sep 2005 21:37:33 +0000 (21:37 +0000)
committerWez Furlong <wez@php.net>
Mon, 26 Sep 2005 21:37:33 +0000 (21:37 +0000)
ext/pdo_odbc/odbc_driver.c

index 99e05e1322a6d53256dc0dbced19e0ac214f750b..5ae45a7e64fe23c40e74e9908b1a141354a74f64 100755 (executable)
@@ -59,7 +59,7 @@ static int pdo_odbc_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *inf
 void pdo_odbc_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, PDO_ODBC_HSTMT statement, char *what, const char *file, int line TSRMLS_DC) /* {{{ */
 {
        RETCODE rc;
-       SWORD   errmsgsize;
+       SWORD   errmsgsize = 0;
        pdo_odbc_db_handle *H = (pdo_odbc_db_handle*)dbh->driver_data;
        pdo_odbc_errinfo *einfo = &H->einfo;
        pdo_odbc_stmt *S = NULL;
@@ -79,6 +79,10 @@ void pdo_odbc_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, PDO_ODBC_HSTMT statement,
        rc = SQLError(H->env, H->dbc, statement, einfo->last_state, &einfo->last_error,
                        einfo->last_err_msg, sizeof(einfo->last_err_msg)-1, &errmsgsize);
 
+       if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
+               errmsgsize = 0;
+       }
+
        einfo->last_err_msg[errmsgsize] = '\0';
        einfo->file = file;
        einfo->line = line;