Skip to content

Commit

Permalink
Fix memory leak on ZEND_FFI_TYPE_CHAR conversion failure
Browse files Browse the repository at this point in the history
The success path frees tmp_str, but the error path does not.

Closes phpGH-17243.
  • Loading branch information
nielsdos committed Dec 23, 2024
1 parent fcbfd5a commit a7f7e16
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ PHP NEWS

- FFI:
. Fixed bug #79075 (FFI header parser chokes on comments). (nielsdos)
. Fix memory leak on ZEND_FFI_TYPE_CHAR conversion failure. (nielsdos)

- Filter:
. Fixed bug GH-16944 (Fix filtering special IPv4 and IPv6 ranges, by using
Expand Down
1 change: 1 addition & 0 deletions ext/ffi/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ static zend_always_inline zend_result zend_ffi_zval_to_cdata(void *ptr, zend_ffi
if (ZSTR_LEN(str) == 1) {
*(char*)ptr = ZSTR_VAL(str)[0];
} else {
zend_tmp_string_release(tmp_str);
zend_ffi_assign_incompatible(value, type);
return FAILURE;
}
Expand Down

0 comments on commit a7f7e16

Please sign in to comment.