From 4b746fce1c6f873a696ace4c98e0981a059f35c9 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 10 Sep 2017 18:39:29 +0200 Subject: 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. --- NEWS | 3 +++ ext/gettext/gettext.c | 8 ++++---- ext/gettext/tests/bug73730.phpt | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 ext/gettext/tests/bug73730.phpt diff --git a/NEWS b/NEWS index 795d67d860..12c5003acc 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,9 @@ PHP NEWS . Fixed bug #75124 (gdImageGrayScale() may produce colors). (cmb) . Fixed bug #75139 (libgd/gd_interpolation.c:1786: suspicious if ?). (cmb) +- Gettext: + . Fixed bug #73730 (textdomain(null) throws in strict mode). (cmb) + - Intl: . Fixed bug #75090 (IntlGregorianCalendar doesn't have constants from parent class). (tpunt) 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-- + +--FILE-- + +===DONE=== +--EXPECT-- +string(8) "messages" +===DONE=== -- cgit v1.2.1