[python-yenc] Fix some minor bugs pointed out by cpychecker (#800187)

konradm konradm at fedoraproject.org
Fri Mar 9 07:41:16 UTC 2012


commit c8f2e7b5bb1c3372228f92792e282e2af33e5d13
Author: Conrad Meyer <cemeyer at uw.edu>
Date:   Thu Mar 8 23:41:07 2012 -0800

    Fix some minor bugs pointed out by cpychecker (#800187)

 python-yenc-0.3-fixes.diff |   78 ++++++++++++++++++++++++++++++++++++++++++++
 python-yenc.spec           |    8 ++++-
 2 files changed, 85 insertions(+), 1 deletions(-)
---
diff --git a/python-yenc-0.3-fixes.diff b/python-yenc-0.3-fixes.diff
new file mode 100644
index 0000000..63f938d
--- /dev/null
+++ b/python-yenc-0.3-fixes.diff
@@ -0,0 +1,78 @@
+--- yenc-0.3.orig/src/_yenc.c	2004-02-24 05:39:46.000000000 -0800
++++ yenc-0.3/src/_yenc.c	2012-03-08 23:38:00.247809904 -0800
+@@ -140,7 +140,6 @@
+ 		int *col
+ 		)
+ {
+-	int encoded;
+ 	int in_ind;
+ 	int out_ind;
+ 	Byte byte;
+@@ -170,7 +169,6 @@
+ 		plain_string:
+ 		output_buffer[out_ind++] = byte;
+ 		(*col)++;
+-		encoded++;
+ 		if(*col >= LINESIZE) {
+ 			output_buffer[out_ind++] = CR;
+ 			output_buffer[out_ind++] = LF;
+@@ -278,8 +276,7 @@
+ 		)
+ {
+ 	PyObject *Py_input_string;
+-	PyObject *Py_output_string;
+-	PyObject *retval;
++	PyObject *retval = NULL;
+ 	
+ 	Byte *input_buffer = NULL;
+ 	Byte *output_buffer = NULL;
+@@ -304,13 +301,14 @@
+ 	input_len = PyString_Size(Py_input_string);
+ 	input_buffer = PyString_AsString(Py_input_string);
+ 	output_buffer = (char *) malloc(( 2 * input_len / LINESIZE + 1 ) * ( LINESIZE + 2 ));
++	if(!output_buffer)
++		goto out;
+ 	output_len = encode_buffer(input_buffer, output_buffer, input_len, &crc, &col);
+-	Py_output_string = PyString_FromStringAndSize(output_buffer, output_len);
+-	retval = Py_BuildValue("(S,i,i)", Py_output_string, crc.crc, col);
+-
+-	free(output_buffer);
+-	Py_DECREF(Py_output_string);
++	retval = Py_BuildValue("(s#,i,i)", output_buffer, output_len, crc.crc, col);
+ 	
++out:
++	if(output_buffer)
++		free(output_buffer);
+ 	return retval;
+ }
+ 
+@@ -379,8 +377,7 @@
+ 		)
+ {
+ 	PyObject *Py_input_string;
+-	PyObject *Py_output_string;
+-	PyObject *retval;
++	PyObject *retval = NULL;
+ 	
+ 	char *input_buffer = NULL;
+ 	char *output_buffer = NULL;
+@@ -405,13 +402,14 @@
+ 	input_len = PyString_Size(Py_input_string);
+ 	input_buffer = PyString_AsString(Py_input_string);
+ 	output_buffer = (char *) malloc( input_len );
++	if(!output_buffer)
++		goto out;
+ 	output_len = decode_buffer(input_buffer, output_buffer, input_len, &crc, &escape);
+-	Py_output_string = PyString_FromStringAndSize(output_buffer, output_len);
+-	retval = Py_BuildValue("(S,i,i)", Py_output_string, crc.crc, escape);
+-	
+-	free(output_buffer);
+-	Py_DECREF(Py_output_string);
++	retval = Py_BuildValue("(s#,i,i)", output_buffer, output_len, crc.crc, escape);
+ 
++out:
++	if(output_buffer)
++		free(output_buffer);
+ 	return retval;
+ }
+ 
diff --git a/python-yenc.spec b/python-yenc.spec
index 4278ca9..4d0f2a5 100644
--- a/python-yenc.spec
+++ b/python-yenc.spec
@@ -2,12 +2,14 @@
 
 Name:           python-yenc
 Version:        0.3
-Release:        10%{?dist}
+Release:        11%{?dist}
 Summary:        yEnc Module for Python
 Group:          Development/Languages
 License:        GPLv2+
 URL:            http://www.hellanzb.com/trac/
 Source0:        http://www.hellanzb.com/hellanzb-content/yenc-%{version}.tar.gz
+# Fix some minor bugs (#800187):
+Patch0:         python-yenc-0.3-fixes.diff
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires:  python-devel
 BuildRequires:  python-setuptools-devel
@@ -20,6 +22,7 @@ in messages on Usenet or via e-mail.
 
 %prep
 %setup -q -n yenc-%{version}
+%patch0 -p1
 
 
 %build
@@ -47,6 +50,9 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Thu Mar 8 2012 Conrad Meyer <konrad at tylerc.org> - 0.3-11
+- Fix some minor bugs pointed out by cpychecker (#800187)
+
 * Sat Jan 14 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.3-10
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
 


More information about the scm-commits mailing list