From 7cdffd158736df3ea4ec17169744b7a07a99651b Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Mon, 6 Apr 2026 11:41:59 -0300 Subject: [PATCH] ext/pdo_odbc: Require non-empty string when building string buffer A buggy driver could do this and get PDO_ODBC stuck in this loop. Require a non-empty string, so an empty one breaks like the SQL_NO_DATA case. Fixes GH-21534 --- ext/pdo_odbc/odbc_stmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index ea9d5c788f571..c114f721a7a79 100644 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -710,7 +710,7 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, zval *result, enum pdo str = zend_string_realloc(str, used + 256, 0); memcpy(ZSTR_VAL(str) + used, buf2, 256); used = used + 255; - } else if (rc==SQL_SUCCESS) { + } else if (rc == SQL_SUCCESS && C->fetched_len != 0) { str = zend_string_realloc(str, used + C->fetched_len, 0); memcpy(ZSTR_VAL(str) + used, buf2, C->fetched_len); used = used + C->fetched_len;