php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch enchant_unaligned_memory_access.patch for Enchant related Bug #51289

Patch version 2010-03-13 03:35 UTC

Return to Bug #51289 | Download this patch
Patch Revisions:

Developer: geissert@php.net

Description: Fix an unaligned memory access in enchant_dict_suggest()
Origin: vendor
Forwarded: http://bugs.php.net/51289
Last-Update: 2010-03-12

Index: php/ext/enchant/enchant.c
===================================================================
--- php.orig/ext/enchant/enchant.c
+++ php/ext/enchant/enchant.c
@@ -724,6 +724,7 @@ PHP_FUNCTION(enchant_dict_quick_check)
 
 	if (enchant_dict_check(pdict->pdict, word, wordlen) > 0) {
 		int n_sugg;
+		size_t n_sugg_st;
 		char **suggs;
 
 		if (!sugg && ZEND_NUM_ARGS() == 2) {
@@ -732,7 +733,8 @@ PHP_FUNCTION(enchant_dict_quick_check)
 
 		array_init(sugg);
 
-		suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, (size_t *) &n_sugg);
+		suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, n_sugg_st);
+		memcpy(&n_sugg, &n_sugg_st, sizeof(n_sugg));
 		if (suggs && n_sugg) {
 			int i;
 			for (i = 0; i < n_sugg; i++) {
@@ -777,6 +779,7 @@ PHP_FUNCTION(enchant_dict_suggest)
 	char **suggs;
 	enchant_dict *pdict;
 	int n_sugg;
+	size_t n_sugg_st;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
 		RETURN_FALSE;
@@ -784,7 +787,8 @@ PHP_FUNCTION(enchant_dict_suggest)
 
 	PHP_ENCHANT_GET_DICT;
 
-	suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, (size_t *)&n_sugg);
+	suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg_st);
+	memcpy(&n_sugg, &n_sugg_st, sizeof(n_sugg));
 	if (suggs && n_sugg) {
 		int i;
 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 18:01:31 2024 UTC