-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed GH-17398: bcmul memory leak #17615
Conversation
freed regardless of the refcount.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments.
Also a small nit: normally our commit subjects are formatted as Fix GH-<nr>: <issue title>
instead of Fixed
and instead of the description what you changed.
ext/bcmath/libbcmath/src/init.c
Outdated
*num = NULL; | ||
} | ||
|
||
void bc_force_free_numbers(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During GSHUTDOWN you should use the passed bcmath_globals
instead of BCG to avoid freeing the wrong data in ZTS. In fact, If I were you I'd call _bc_force_free_number
directly in GSHUTDOWN.
ext/bcmath/libbcmath/src/init.c
Outdated
@@ -82,6 +82,20 @@ void bc_init_numbers(void) | |||
BCG(_two_)->n_value[0] = 2; | |||
} | |||
|
|||
static void _bc_force_free_number(bc_num *num) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function names starting with underscores should be avoided in new code because in C a name starting with underscore is reserved.
BCG
release processing of PHP_GSHUTDOWN_FUNCTION()
@nielsdos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems right to me, and works locally. Please wait for CI before merging.
Also be careful when merging up: there is only one allocation for bc_num in 8.4 and up so you'll have to adjust the freeing code upon merging.
The deleted line has returned, so delete it again.
* PHP-8.4: follow up for #17615
take2 of #17594