diff Objects/unicodeobject.c @ 17273:536cc126fb9f 2.0

- #122162 -- unicodeobject.c --- Fix unicode .split() off-by-one - Loosely based on patch #103249 -- Fix core dumps in PyUnicode_Count
author Moshe Zadka <moshez@math.huji.ac.il>
date Sat, 31 Mar 2001 06:48:52 +0000
parents a349b89bf10e
children
line wrap: on
line diff
--- a/Objects/unicodeobject.c	Fri Mar 30 21:01:09 2001 +0000
+++ b/Objects/unicodeobject.c	Sat Mar 31 06:48:52 2001 +0000
@@ -2357,6 +2357,17 @@
 {
     int count = 0;
 
+    if (start < 0)
+        start += self->length;
+    if (start < 0)
+        start = 0;
+    if (end > self->length)
+        end = self->length;
+    if (end < 0)
+        end += self->length;
+    if (end < 0)
+        end = 0;
+
     if (substring->length == 0)
 	return (end - start + 1);
 
@@ -2925,7 +2936,7 @@
     int sublen = substring->length;
     PyObject *str;
 
-    for (i = j = 0; i < len - sublen; ) {
+    for (i = j = 0; i <= len - sublen; ) {
 	if (Py_UNICODE_MATCH(self, i, substring)) {
 	    if (maxcount-- <= 0)
 		break;