-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix #78620: Out of memory error #4766
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
Conversation
If the integer addition in `ZEND_MM_ALIGNED_SIZE_EX` overflows, the macro evaluates to `0`, what we should catch early.
We also add a comment.
|
Thanks! Applied as 8ce04df. |
| if (UNEXPECTED(new_size == 0)) { | ||
| /* overflow in ZEND_MM_ALIGNED_SIZE_EX */ | ||
| goto memory_limit_exhausted; | ||
| } |
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.
On second thought, this fix doesn't look quite right ... especially the fact that this is in the #if ZEND_MM_LIMIT branch, while this check is necessary even without memory limit. I think it would be better to move this check outside of #if ZEND_MM_LIMIT and generate a "Possible integer overflow in memory allocation (%zu + %zu)" style error for that case.
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.
Okay, reverted for now (f2fb37a). Will come up with a better solution ASAP.
This reverts commit 8ce04df. Cf. <#4766 (comment)>.
If the integer addition in
ZEND_MM_ALIGNED_SIZE_EXoverflows, themacro evaluates to
0, what we should catch early.There are many more uses of
ZEND__MM_ALIGNED_SIZE_EX; not sure if overflow can happen there as well.