[Python-checkins] r65785 - python/trunk/Objects/bytearrayobject.c

amaury.forgeotdarc python-checkins at python.org
Sun Aug 17 23:05:18 CEST 2008


Author: amaury.forgeotdarc
Date: Sun Aug 17 23:05:18 2008
New Revision: 65785

Log:
Fix a refleak in bytearray.split and bytearray.rsplit, detected by 
   regrtest.py -R:: test_bytes


Modified:
   python/trunk/Objects/bytearrayobject.c

Modified: python/trunk/Objects/bytearrayobject.c
==============================================================================
--- python/trunk/Objects/bytearrayobject.c	(original)
+++ python/trunk/Objects/bytearrayobject.c	Sun Aug 17 23:05:18 2008
@@ -2295,8 +2295,11 @@
         PyBuffer_Release(&vsub);
         return NULL;
     }
-    if (n == 1)
-        return split_char(s, len, sub[0], maxsplit);
+    if (n == 1) {
+        list = split_char(s, len, sub[0], maxsplit);
+        PyBuffer_Release(&vsub);
+        return list;
+    }
 
     list = PyList_New(PREALLOC_SIZE(maxsplit));
     if (list == NULL) {
@@ -2527,8 +2530,11 @@
         PyBuffer_Release(&vsub);
         return NULL;
     }
-    else if (n == 1)
-        return rsplit_char(s, len, sub[0], maxsplit);
+    else if (n == 1) {
+        list = rsplit_char(s, len, sub[0], maxsplit);
+        PyBuffer_Release(&vsub);
+        return list;
+    }
 
     list = PyList_New(PREALLOC_SIZE(maxsplit));
     if (list == NULL) {


More information about the Python-checkins mailing list