Skip to content

Commit 786090b

Browse files
committed
pdo_odbc: Fix memory leak if WideCharToMultiByte() fails
Closes GH-18788.
1 parent ef92e06 commit 786090b

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ PHP NEWS
3434
. Add missing filter cleanups on phar failure. (nielsdos)
3535
. Fixed bug GH-18642 (Signed integer overflow in ext/phar fseek). (nielsdos)
3636

37+
- PDO ODBC:
38+
. Fix memory leak if WideCharToMultiByte() fails. (nielsdos)
39+
3740
- PGSQL:
3841
. Fix warning not being emitted when failure to cancel a query with
3942
pg_cancel_query(). (Girgias)

ext/pdo_odbc/odbc_stmt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ static int pdo_odbc_ucs22utf8(pdo_stmt_t *stmt, int is_unicode, zval *result)
104104
zend_string *str = zend_string_alloc(ret, 0);
105105
ret = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR) Z_STRVAL_P(result), Z_STRLEN_P(result)/sizeof(WCHAR), ZSTR_VAL(str), ZSTR_LEN(str), NULL, NULL);
106106
if (ret == 0) {
107+
zend_string_efree(str);
107108
return PDO_ODBC_CONV_FAIL;
108109
}
109110

0 commit comments

Comments
 (0)