summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-02-28 13:18:00 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2020-02-28 15:43:44 +0100
commit6adb885966502f53c69b9aeb0e2cbbeac3d6c65a (patch)
treec1b85890d795bd9a8f655e5c8c6de51d996425a8
parentd31fc591e0a852c69b81b3311b3609221f66c445 (diff)
downloadphp-git-6adb885966502f53c69b9aeb0e2cbbeac3d6c65a.tar.gz
Fix #79311: enchant_dict_suggest() fails on big endian architecture
For obvious reasons, we must not assign a `size_t` value to an `int` variable using memcpy(). However, there is actually no need for the intermediate `n_sugg_st` here, if we use the proper types in the first place. A regression test is not necessary, because dict_suggest.phpt already exhibits the erroneous behavior on big endian architectures.
-rw-r--r--NEWS4
-rw-r--r--ext/enchant/enchant.c16
2 files changed, 10 insertions, 10 deletions
diff --git a/NEWS b/NEWS
index 353f7b0a13..127d60c1fe 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,10 @@ PHP NEWS
cmb)
. Fixed bug #79271 (DOMDocumentType::$childNodes is NULL). (cmb)
+- Enchant:
+ . Fixed bug #79311 (enchant_dict_suggest() fails on big endian architecture).
+ (cmb)
+
- MySQLi:
. Fixed bug #64032 (mysqli reports different client_version). (cmb)
diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c
index 063b419bd3..a34859b28c 100644
--- a/ext/enchant/enchant.c
+++ b/ext/enchant/enchant.c
@@ -723,18 +723,16 @@ PHP_FUNCTION(enchant_dict_quick_check)
PHP_ENCHANT_GET_DICT;
if (enchant_dict_check(pdict->pdict, word, wordlen) > 0) {
- int n_sugg;
- size_t n_sugg_st;
+ size_t n_sugg;
char **suggs;
if (!sugg && ZEND_NUM_ARGS() == 2) {
RETURN_FALSE;
}
- suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg_st);
- memcpy(&n_sugg, &n_sugg_st, sizeof(n_sugg));
+ suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg);
if (suggs && n_sugg) {
- int i;
+ size_t i;
for (i = 0; i < n_sugg; i++) {
add_next_index_string(sugg, suggs[i]);
}
@@ -776,8 +774,7 @@ PHP_FUNCTION(enchant_dict_suggest)
size_t wordlen;
char **suggs;
enchant_dict *pdict;
- int n_sugg;
- size_t n_sugg_st;
+ size_t n_sugg;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &dict, &word, &wordlen) == FAILURE) {
RETURN_FALSE;
@@ -785,10 +782,9 @@ PHP_FUNCTION(enchant_dict_suggest)
PHP_ENCHANT_GET_DICT;
- suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg_st);
- memcpy(&n_sugg, &n_sugg_st, sizeof(n_sugg));
+ suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg);
if (suggs && n_sugg) {
- int i;
+ size_t i;
array_init(return_value);
for (i = 0; i < n_sugg; i++) {