Improve check for offset out of range

This commit is contained in:
Guido van Rossum 1992-09-03 20:35:01 +00:00
parent f2c8beba0b
commit 3d1e146086
1 changed files with 8 additions and 4 deletions

View File

@ -98,6 +98,10 @@ reg_match(re, args)
err_clear();
if (!getargs(args, "(s#i)", &buffer, &size, &offset))
return NULL;
if (offset < 0 || offset > size) {
err_setstr(RegexError, "match offset out of range");
return NULL;
}
}
re->re_regs_valid = 0;
result = re_match(&re->re_patbuf, buffer, size, offset, &re->re_regs);
@ -128,10 +132,10 @@ reg_search(re, args)
err_clear();
if (!getargs(args, "(s#i)", &buffer, &size, &offset))
return NULL;
}
if (offset < 0 || offset > size) {
err_setstr(RegexError, "search offset out of range");
return NULL;
if (offset < 0 || offset > size) {
err_setstr(RegexError, "search offset out of range");
return NULL;
}
}
/* NB: In Emacs 18.57, the documentation for re_search[_2] and
the implementation don't match: the documentation states that