af9dc8
From bdfe457a2c1b47209e32783b3a6447e81baf179a Mon Sep 17 00:00:00 2001
af9dc8
From: Stanislav Malyshev <stas@php.net>
af9dc8
Date: Mon, 16 Feb 2015 06:50:10 +0100
af9dc8
Subject: [PATCH] Port for for bug #68552
af9dc8
af9dc8
---
af9dc8
 NEWS                  | 6 ++++++
af9dc8
 ext/enchant/enchant.c | 7 +++----
af9dc8
 2 files changed, 9 insertions(+), 4 deletions(-)
af9dc8
af9dc8
diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c
af9dc8
index 6de2fea..0eb8144 100644
af9dc8
--- a/ext/enchant/enchant.c
af9dc8
+++ b/ext/enchant/enchant.c
af9dc8
@@ -550,13 +550,12 @@ PHP_FUNCTION(enchant_broker_request_dict)
af9dc8
 
af9dc8
 	d = enchant_broker_request_dict(pbroker->pbroker, (const char *)tag);
af9dc8
 	if (d) {
af9dc8
+		pos = pbroker->dictcnt++;
af9dc8
 		if (pbroker->dictcnt) {
af9dc8
 			pbroker->dict = (enchant_dict **)erealloc(pbroker->dict, sizeof(enchant_dict *) * pbroker->dictcnt);
af9dc8
-			pos = pbroker->dictcnt++;
af9dc8
 		} else {
af9dc8
 			pbroker->dict = (enchant_dict **)emalloc(sizeof(enchant_dict *));
af9dc8
 			pos = 0;
af9dc8
-			pbroker->dictcnt++;
af9dc8
 		}
af9dc8
 
af9dc8
 		dict = pbroker->dict[pos] = (enchant_dict *)emalloc(sizeof(enchant_dict));
af9dc8
@@ -607,14 +606,14 @@ PHP_FUNCTION(enchant_broker_request_pwl_dict)
af9dc8
 
af9dc8
 	d = enchant_broker_request_pwl_dict(pbroker->pbroker, (const char *)pwl);
af9dc8
 	if (d) {
af9dc8
+		pos = pbroker->dictcnt++;
af9dc8
 		if (pbroker->dictcnt) {
af9dc8
-			pos = pbroker->dictcnt++;
af9dc8
 			pbroker->dict = (enchant_dict **)erealloc(pbroker->dict, sizeof(enchant_dict *) * pbroker->dictcnt);
af9dc8
 		} else {
af9dc8
 			pbroker->dict = (enchant_dict **)emalloc(sizeof(enchant_dict *));
af9dc8
 			pos = 0;
af9dc8
-			pbroker->dictcnt++;
af9dc8
 		}
af9dc8
+
af9dc8
 		dict = pbroker->dict[pos] = (enchant_dict *)emalloc(sizeof(enchant_dict));
af9dc8
 		dict->id = pos;
af9dc8
 		dict->pbroker = pbroker;
af9dc8
-- 
af9dc8
2.1.4
af9dc8