Bug #63121 [Opn->Csd]: enchant_broker_free_dict destroys broker resource
| From: | cmb@php.net | Date: | Tue, 02 Jan 2018 15:26:38 +0000 |
| Subject: | Bug #63121 [Opn->Csd]: enchant_broker_free_dict destroys broker resource | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213357@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63121&edit=1
ID: 63121
Updated by: cmb@php.net
Reported by: robert dot johnson at icap dot com
Summary: enchant_broker_free_dict destroys broker resource
-Status: Open
+Status: Closed
Type: Bug
Package: Enchant related
Operating System: Win XP SP 3
PHP Version: 5.4.7
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> For some reason the broker resource is indeed freed when the
> dict is freed
No. zend_list_delete() only decreases the refcount here.
Actually, I'm not able to reproduce the reported behavior under
PHP-7.1, so I assume this issue had been fixed in the meantime.
Previous Comments:
------------------------------------------------------------------------
[2018-01-01 18:03:49] cmb@php.net
For some reason the broker resource is indeed freed when the dict
is freed[1].
[1] <https://github.com/php/php-src/blob/PHP-7.2.0/ext/enchant/enchant.c#L276>
------------------------------------------------------------------------
[2012-09-20 11:32:06] robert dot johnson at icap dot com
Further testing reveals that Enchant broker resource is also destroyed when the PWL dictionary
resource goes out of scope.
------------------------------------------------------------------------
[2012-09-20 11:22:00] robert dot johnson at icap dot com
This code works, so bug is probably related to function enchant_broker_request_pwl_dict():
if ( PHP_SAPI != 'cli' )
header('Content-Type:text/plain;charset=UTF-8');
$r = enchant_broker_init();
debug_zval_dump($r);
$d = enchant_broker_request_dict($r, 'en-gb');
enchant_broker_free_dict($d);
debug_zval_dump($r);
echo "End.\r\n";
Result:
resource(1) of type (enchant_broker) refcount(2)
resource(1) of type (enchant_broker) refcount(2)
End.
------------------------------------------------------------------------
[2012-09-20 11:11:30] robert dot johnson at icap dot com
Description:
------------
Calling enchant_broker_free_dict destroys the resource created by enchant_broker_init(), instead of
just the dictionary resource.
Test script:
---------------
if ( PHP_SAPI != 'cli' )
header('Content-Type:text/plain;charset=UTF-8');
$r = enchant_broker_init();
debug_zval_dump($r);
$d = enchant_broker_request_pwl_dict($r, 'c:\mydict.dic');
enchant_broker_free_dict($d);
debug_zval_dump($r);
echo "End.\r\n";
Expected result:
----------------
resource(1) of type (enchant_broker) refcount(2)
resource(1) of type (enchant_broker) refcount(2)
End.
Actual result:
--------------
resource(1) of type (enchant_broker) refcount(2)
resource(1) of type (Unknown) refcount(2)
End.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63121&edit=1