Fixed bug #76532 (excessive memory usage in mb_strimwidth)#3348
Fixed bug #76532 (excessive memory usage in mb_strimwidth)#3348MarcusSchwarz wants to merge 1 commit intophp:PHP-7.1from MarcusSchwarz:php-strimwdith
Conversation
ext/mbstring/libmbfl/mbfl/mbfilter.c
Outdated
| result->no_language = string->no_language; | ||
| result->no_encoding = string->no_encoding; | ||
| mbfl_memory_device_init(&pc.device, width, 0); | ||
| mbfl_memory_device_init(&pc.device, string->len, 0); |
There was a problem hiding this comment.
This should use width or string->len, whichever is lower.
|
Merged as bf5a802 into 7.1+. Thanks! |
|
Is it really okay to rely on the Also, the bug report claims that the issue occurs for |
|
@cmb69 This PR fixes the issue of unnecessary over-allocation if the trim width exceeds the string length. The type conversion is a separate problem and already fixed in PHP 7.3 by the migration to size_t. |
|
@cmb69 This PR fixes the practical concern, and fully correct behavior is not possible on older versions, as the libmbfl support is not there. Making it fail nicer is IMHO a waste of time. However, feel free to add a check (just need to make sure it's not merged into master). |
No description provided.