summaryrefslogtreecommitdiffstats
path: root/Modules/stropmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-05-14 02:36:29 (GMT)
committerGuido van Rossum <guido@python.org>1998-05-14 02:36:29 (GMT)
commit4ccda15cd33faa6898c78772634e61fa4212a439 (patch)
tree9fea1b7a201ac8546cab64765c79b8e4e7087626 /Modules/stropmodule.c
parented33a3f41560a8847179f92fa004ba1741215b7b (diff)
downloadcpython-4ccda15cd33faa6898c78772634e61fa4212a439.zip
cpython-4ccda15cd33faa6898c78772634e61fa4212a439.tar.gz
cpython-4ccda15cd33faa6898c78772634e61fa4212a439.tar.bz2
strop_replace(): balk if the pattern string is empty.
Diffstat (limited to 'Modules/stropmodule.c')
-rw-r--r--Modules/stropmodule.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index e9e9039..73c2d85 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();