Skip to content

ext/Intl: Fix memory leaks when calling Collator::__construct() or Spoofchecker::__construct() twice.#22386

Closed
LamentXU123 wants to merge 1 commit into
php:PHP-8.4from
LamentXU123:intl-cons
Closed

ext/Intl: Fix memory leaks when calling Collator::__construct() or Spoofchecker::__construct() twice.#22386
LamentXU123 wants to merge 1 commit into
php:PHP-8.4from
LamentXU123:intl-cons

Conversation

@LamentXU123

@LamentXU123 LamentXU123 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Both constructors could be called again on an already initialized object and would overwrite the existing ICU handles:

  • Collator overwrote the UCollator *
  • Spoofchecker overwrote the USpoofChecker * / USpoofCheckResult *

The previous handles were not released before being overwritten, so only the newly stored handles could be cleaned up during object destruction.

This aligns these classes with other ext/intl classes by rejecting double construction with an Error. The similar bug happens on listformatter but I want to fix it in a separate PR because it need to target a different branch. (i.e. 8.5)

LamentXU123 added a commit that referenced this pull request Jun 22, 2026
* PHP-8.5:
  ext/intl: Fix double construction leaks (#22386)
pull Bot pushed a commit to Ammarpad/php-src that referenced this pull request Jun 22, 2026
* PHP-8.4:
  ext/intl: Fix double construction leaks (php#22386)
LamentXU123 added a commit that referenced this pull request Jun 22, 2026
* PHP-8.5:
  ext/intl: Fix Spoofchecker build after double construction change (#22386)
pull Bot pushed a commit to ppker/php-src that referenced this pull request Jun 22, 2026
…p#22386)

PHP-8.5 no longer declares a zend_error_handling variable in
Spoofchecker::__construct(). The previous merge from PHP-8.4 carried forward a
zend_replace_error_handling() call that references the removed local variable.

Remove the stale call so PHP-8.5 and branches merged from it build again.
pull Bot pushed a commit to edisplay/php-src that referenced this pull request Jun 22, 2026
IntlListFormatter stores a UListFormatter pointer. Calling the constructor
again on an already initialized object overwrote the existing pointer and
leaked the previous formatter.

Follow up to the double construction fixes from phpGH-22386 by rejecting repeated
IntlListFormatter::__construct() calls.

Closes php#22394
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants