]> granicus.if.org Git - python/commitdiff
strop_replace(): balk if the pattern string is empty.
authorGuido van Rossum <guido@python.org>
Thu, 14 May 1998 02:36:29 +0000 (02:36 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 14 May 1998 02:36:29 +0000 (02:36 +0000)
Modules/stropmodule.c

index e9e9039397fa96ed8b903201c42668071e3cb64f..73c2d85683243d722cdd97eeee6de9aa31baea03 100644 (file)
@@ -1091,6 +1091,10 @@ strop_replace(self, args)
                              &str, &len, &pat, &pat_len, &sub, &sub_len,
                              &count))
                return NULL;
+       if (pat_len <= 0) {
+               PyErr_SetString(PyExc_ValueError, "empty pattern string");
+               return NULL;
+       }
        new_s = mymemreplace(str,len,pat,pat_len,sub,sub_len,count,&out_len);
        if (new_s == NULL) {
                PyErr_NoMemory();