From: Guido van Rossum Date: Thu, 14 May 1998 02:36:29 +0000 (+0000) Subject: strop_replace(): balk if the pattern string is empty. X-Git-Tag: v1.5.2a1~640 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4ccda15cd33faa6898c78772634e61fa4212a439;p=thirdparty%2FPython%2Fcpython.git strop_replace(): balk if the pattern string is empty. --- diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c index e9e9039397fa..73c2d8568324 100644 --- a/Modules/stropmodule.c +++ b/Modules/stropmodule.c @@ -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();