Skip to content

Commit

Permalink
Throw ValueError on empty tag in enchant_broker_request_dict()
Browse files Browse the repository at this point in the history
  • Loading branch information
Girgias committed Jul 31, 2020
1 parent 0ba31e1 commit 9a71d47
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/enchant/enchant.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ PHP_FUNCTION(enchant_broker_request_dict)
PHP_ENCHANT_GET_BROKER;

if (taglen == 0) {
php_error_docref(NULL, E_WARNING, "Tag cannot be empty");
RETURN_FALSE;
zend_argument_value_error(2, "cannot be empty");
RETURN_THROWS();
}

pdict = enchant_broker_request_dict(pbroker->pbroker, (const char *)tag);
Expand Down
20 changes: 20 additions & 0 deletions ext/enchant/tests/broker_request_dict_error_on_empty_tag.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
enchant_broker_request_dict() must throw ValueError on empty tag
--SKIPIF--
<?php
if(!extension_loaded('enchant')) die('skip, enchant not loader');
if (!is_object(enchant_broker_init())) {die("skip, resource dont load\n");}
?>
--FILE--
<?php
$broker = enchant_broker_init();

try {
var_dump(enchant_broker_request_dict($broker, ''));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}

?>
--EXPECT--
enchant_broker_request_dict(): Argument #2 ($tag) cannot be empty

0 comments on commit 9a71d47

Please sign in to comment.