1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

pdo_odbc: Fix memory leak if WideCharToMultiByte() fails

Closes GH-18788.
This commit is contained in:
Niels Dossche
2025-06-07 00:36:08 +02:00
parent ef92e06de1
commit 786090b35d
2 changed files with 4 additions and 0 deletions

3
NEWS
View File

@@ -34,6 +34,9 @@ PHP NEWS
. Add missing filter cleanups on phar failure. (nielsdos)
. Fixed bug GH-18642 (Signed integer overflow in ext/phar fseek). (nielsdos)
- PDO ODBC:
. Fix memory leak if WideCharToMultiByte() fails. (nielsdos)
- PGSQL:
. Fix warning not being emitted when failure to cancel a query with
pg_cancel_query(). (Girgias)

View File

@@ -104,6 +104,7 @@ static int pdo_odbc_ucs22utf8(pdo_stmt_t *stmt, int is_unicode, zval *result)
zend_string *str = zend_string_alloc(ret, 0);
ret = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR) Z_STRVAL_P(result), Z_STRLEN_P(result)/sizeof(WCHAR), ZSTR_VAL(str), ZSTR_LEN(str), NULL, NULL);
if (ret == 0) {
zend_string_efree(str);
return PDO_ODBC_CONV_FAIL;
}