[pyhunspell] Add pyhunspell-0.1-rhbz800116.patch from Eugene Sizikov

Mike FABIAN mfabian at fedoraproject.org
Fri Jan 11 15:38:53 UTC 2013


commit 1f9170d1067313dae5f3bd79b01dbc66a7aa47a7
Author: Mike FABIAN <mfabian at redhat.com>
Date:   Fri Jan 11 13:12:00 2013 +0100

    Add pyhunspell-0.1-rhbz800116.patch from Eugene Sizikov
    
    Resolves: #800116 - Bugs found in pyhunspell-0.1-6.fc17 using gcc-with-cpychecker static analyzer

 pyhunspell-0.1-rhbz800116.patch |  159 +++++++++++++++++++++++++++++++++++++++
 pyhunspell.spec                 |   13 +++-
 2 files changed, 170 insertions(+), 2 deletions(-)
---
diff --git a/pyhunspell-0.1-rhbz800116.patch b/pyhunspell-0.1-rhbz800116.patch
new file mode 100644
index 0000000..0f64e60
--- /dev/null
+++ b/pyhunspell-0.1-rhbz800116.patch
@@ -0,0 +1,159 @@
+Index: hunspell.c
+===================================================================
+--- hunspell.c	(revision 6)
++++ hunspell.c	(working copy)
+@@ -54,7 +54,10 @@
+ static PyObject *
+ HunSpell_get_dic_encoding(HunSpell * self, PyObject *args)
+ {
+-	return Py_BuildValue("s", Hunspell_get_dic_encoding(self->handle));
++	char *retvalue;
++
++	retvalue = Hunspell_get_dic_encoding(self->handle);
++	return PyString_FromString(retvalue);
+ }
+ 
+ static PyObject *
+@@ -75,17 +78,24 @@
+ HunSpell_suggest(HunSpell * self, PyObject *args)
+ {
+ 	char *word, **slist;
+-	int i, num_slist;
+-	PyObject *slist_list;
++	int i, num_slist, ret;
++	PyObject *slist_list, *pystr;
+ 
+ 	if (!PyArg_ParseTuple(args, "s", &word))
+ 		return NULL;
+ 
+ 	slist_list = PyList_New(0);
++	if (!slist_list) {
++		return NULL;
++	}
+ 	num_slist = Hunspell_suggest(self->handle, &slist, word);
+ 
+-	for (i = 0; i < num_slist; i++) {
+-		PyList_Append(slist_list, Py_BuildValue("s", slist[i]));
++	for (i = 0, ret = 0; !ret && i < num_slist; i++) {
++		pystr = PyString_FromString(slist[i]);
++		if (!pystr)
++			break;
++		ret = PyList_Append(slist_list, pystr);
++		Py_DECREF(pystr);
+ 	}
+ 
+ 	Hunspell_free_list(self->handle, &slist, num_slist);
+@@ -96,17 +106,24 @@
+ HunSpell_analyze(HunSpell * self, PyObject *args)
+ {
+ 	char *word, **slist;
+-	int i, num_slist;
+-	PyObject *slist_list;
++	int i, num_slist, ret;
++	PyObject *slist_list, *pystr;
+ 
+ 	if (!PyArg_ParseTuple(args, "s", &word))
+ 		return NULL;
+ 
+ 	slist_list = PyList_New(0);
++	if (!slist_list) {
++		return NULL;
++	}
+ 	num_slist = Hunspell_analyze(self->handle, &slist, word);
+ 
+-	for (i = 0; i < num_slist; i++) {
+-		PyList_Append(slist_list, Py_BuildValue("s", slist[i]));
++	for (i = 0, ret = 0; !ret && i < num_slist; i++) {
++		pystr = PyString_FromString(slist[i]);
++		if (!pystr)
++			break;
++		ret = PyList_Append(slist_list, pystr);
++		Py_DECREF(pystr);
+ 	}
+ 
+ 	Hunspell_free_list(self->handle, &slist, num_slist);
+@@ -117,17 +134,24 @@
+ HunSpell_stem(HunSpell * self, PyObject *args)
+ {
+ 	char *word, **slist;
+-	int i, num_slist;
+-	PyObject *slist_list;
++	int i, num_slist, ret;
++	PyObject *slist_list, *pystr;
+ 
+ 	if (!PyArg_ParseTuple(args, "s", &word))
+ 		return NULL;
+ 
+ 	slist_list = PyList_New(0);
++	if (!slist_list) {
++		return NULL;
++	}
+ 	num_slist = Hunspell_stem(self->handle, &slist, word);
+ 
+-	for (i = 0; i < num_slist; i++) {
+-		PyList_Append(slist_list, Py_BuildValue("s", slist[i]));
++	for (i = 0, ret = 0; !ret && i < num_slist; i++) {
++		pystr = PyString_FromString(slist[i]);
++		if (!pystr)
++			break;
++		ret = PyList_Append(slist_list, pystr);
++		Py_DECREF(pystr);
+ 	}
+ 
+ 	Hunspell_free_list(self->handle, &slist, num_slist);
+@@ -138,17 +162,24 @@
+ HunSpell_generate(HunSpell * self, PyObject *args)
+ {
+ 	char *word1, *word2, **slist;
+-	int i, num_slist;
+-	PyObject *slist_list;
++	int i, num_slist, ret;
++	PyObject *slist_list, *pystr;
+ 
+ 	if (!PyArg_ParseTuple(args, "ss", &word1, &word2))
+ 		return NULL;
+ 
+ 	slist_list = PyList_New(0);
++	if (!slist_list) {
++		return NULL;
++	}
+ 	num_slist = Hunspell_generate(self->handle, &slist, word1, word2);
+ 
+-	for (i = 0; i < num_slist; i++) {
+-		PyList_Append(slist_list, Py_BuildValue("s", slist[i]));
++	for (i = 0, ret = 0; !ret && i < num_slist; i++) {
++		pystr = PyString_FromString(slist[i]);
++		if (!pystr)
++			break;
++		ret = PyList_Append(slist_list, pystr);
++		Py_DECREF(pystr);
+ 	}
+ 
+ 	Hunspell_free_list(self->handle, &slist, num_slist);
+@@ -165,7 +196,7 @@
+ 		return NULL;
+ 	retvalue = Hunspell_add(self->handle, word);
+ 
+-	return Py_BuildValue("i", retvalue);
++	return PyInt_FromLong(retvalue);
+ }
+ 
+ static PyObject *
+@@ -178,7 +209,7 @@
+ 		return NULL;
+ 	retvalue = Hunspell_add_with_affix(self->handle, word, example);
+ 
+-	return Py_BuildValue("i", retvalue);
++	return PyInt_FromLong(retvalue);
+ }
+ 
+ static PyObject *
+@@ -191,7 +222,7 @@
+ 		return NULL;
+ 	retvalue = Hunspell_remove(self->handle, word);
+ 
+-	return Py_BuildValue("i", retvalue);
++	return PyInt_FromLong(retvalue);
+ }
+ 
+ static PyMethodDef HunSpell_methods[] = {
diff --git a/pyhunspell.spec b/pyhunspell.spec
index e805425..8f0b2cb 100644
--- a/pyhunspell.spec
+++ b/pyhunspell.spec
@@ -1,6 +1,6 @@
 Name:           pyhunspell
 Version:        0.1
-Release:        8%{?dist}
+Release:        9%{?dist}
 Summary:        Python bindings for hunspell
 
 Group:          Development/Languages
@@ -11,6 +11,12 @@ Source0:        http://pyhunspell.googlecode.com/files/hunspell-%{version}.tar.g
 BuildRequires:  python2-devel hunspell-devel
 # make it build with hunspell-1.3:
 Patch0: pyhunspell-0.1-hunspell13.patch
+# see:
+# https://bugzilla.redhat.com/show_bug.cgi?id=800116
+# http://code.google.com/p/pyhunspell/issues/detail?id=4
+# patch from Eugene Sizikov:
+# http://code.google.com/p/pyhunspell/issues/detail?id=4#c1
+Patch1: pyhunspell-0.1-rhbz800116.patch
 
 %description
 These are python bindings for hunspell, that allow to use the hunspell library
@@ -20,7 +26,7 @@ in python.
 %prep
 %setup -q -n hunspell-%{version}
 %patch0 -p1 -b .hunspell13
-
+%patch1 -p0 -b .rhbz800116
 
 %build
 CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build
@@ -37,6 +43,9 @@ CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build
 
 
 %changelog
+* Fri Jan 11 2013 Mike FABIAN <mfabian at redhat.com> - 0.1-9
+- Resolves: #800116 - Bugs found in pyhunspell-0.1-6.fc17 using gcc-with-cpychecker static analyzer 
+
 * Wed Jan 09 2013 Till Maas <opensource at till.name> - 0.1-8
 - python site_arch macro is not needed now, remove it
 - remove buildroot tag


More information about the scm-commits mailing list