Skip to content

Commit b0aaf4c

Browse files
committed
changes from feedback
1 parent 1d4d927 commit b0aaf4c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

ext/gettext/gettext.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ PHP_MINFO_FUNCTION(php_gettext)
8181
/* {{{ Set the textdomain to "domain". Returns the current domain */
8282
PHP_FUNCTION(textdomain)
8383
{
84-
char *retval = NULL, *domain_name = NULL;
84+
char *domain_name = NULL, *retval = NULL;
8585
zend_string *domain = NULL;
8686

8787
ZEND_PARSE_PARAMETERS_START(0, 1)
@@ -91,9 +91,10 @@ PHP_FUNCTION(textdomain)
9191

9292
if (domain != NULL) {
9393
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
94-
}
95-
96-
if (domain != NULL && !zend_string_equals_literal(domain, "0")) {
94+
if (zend_string_equals_literal(domain, "0")) {
95+
zend_argument_value_error(1, "cannot be zero");
96+
RETURN_THROWS();
97+
}
9798
domain_name = ZSTR_VAL(domain);
9899
}
99100

ext/gettext/tests/gettext_textdomain-retval.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ echo textdomain('test'), "\n";
1919
echo textdomain(null), "\n";
2020
echo textdomain('foo'), "\n";
2121

22+
try {
23+
textdomain('0');
24+
} catch (\ValueError $e) {
25+
echo $e->getMessage() . PHP_EOL;
26+
}
27+
2228
try {
2329
textdomain('');
2430
} catch (\ValueError $e) {
@@ -29,6 +35,7 @@ try {
2935
test
3036
test
3137
foo
38+
textdomain(): Argument #1 ($domain) cannot be zero
3239
textdomain(): Argument #1 ($domain) cannot be empty
3340
--CREDITS--
3441
Christian Weiske, cweiske@php.net

0 commit comments

Comments
 (0)