diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2017-09-10 18:39:29 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2017-09-10 18:39:29 +0200 |
commit | 4b746fce1c6f873a696ace4c98e0981a059f35c9 (patch) | |
tree | 584598d64fc7d114fa0f594b97a3de2fd67a1b90 /ext/gettext | |
parent | 3fd08a1595299cdd0558978c4ce4c3fc98a8fb06 (diff) | |
download | php-git-4b746fce1c6f873a696ace4c98e0981a059f35c9.tar.gz |
Fixed bug #73730 (textdomain(null) throws in strict mode)
The $text_domain parameter may be NULL, which we have to cater to
explicitly with regard to strict_types.
Diffstat (limited to 'ext/gettext')
-rw-r--r-- | ext/gettext/gettext.c | 8 | ||||
-rw-r--r-- | ext/gettext/tests/bug73730.phpt | 16 |
2 files changed, 20 insertions, 4 deletions
diff --git a/ext/gettext/gettext.c b/ext/gettext/gettext.c index 9cc2ba5a6f..f4d6694cee 100644 --- a/ext/gettext/gettext.c +++ b/ext/gettext/gettext.c @@ -161,16 +161,16 @@ PHP_MINFO_FUNCTION(php_gettext) Set the textdomain to "domain". Returns the current domain */ PHP_NAMED_FUNCTION(zif_textdomain) { - char *domain, *domain_name, *retval; - size_t domain_len; + char *domain = NULL, *domain_name, *retval; + size_t domain_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &domain, &domain_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!", &domain, &domain_len) == FAILURE) { return; } PHP_GETTEXT_DOMAIN_LENGTH_CHECK - if (strcmp(domain, "") && strcmp(domain, "0")) { + if (domain != NULL && strcmp(domain, "") && strcmp(domain, "0")) { domain_name = domain; } else { domain_name = NULL; diff --git a/ext/gettext/tests/bug73730.phpt b/ext/gettext/tests/bug73730.phpt new file mode 100644 index 0000000000..df6d7b0f11 --- /dev/null +++ b/ext/gettext/tests/bug73730.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #73730 (textdomain(null) throws in strict mode) +--SKIPIF-- +<?php +if (!extension_loaded('gettext')) die('skip gettext extension is not available'); +?> +--FILE-- +<?php +declare(strict_types=1); + +var_dump(textdomain(null)); +?> +===DONE=== +--EXPECT-- +string(8) "messages" +===DONE=== |