strop_replace(): balk if the pattern string is empty.

This commit is contained in:
Guido van Rossum 1998-05-14 02:36:29 +00:00
parent ed33a3f415
commit 4ccda15cd3
1 changed files with 4 additions and 0 deletions

View 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();