We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
skip_bytes
tell_impl
1 parent 64b052a commit 0ddcffaCopy full SHA for 0ddcffa
1 file changed
Modules/_io/textio.c
@@ -2933,7 +2933,13 @@ _io_TextIOWrapper_tell_impl(textio *self)
2933
2934
/* Fast search for an acceptable start point, close to our
2935
current pos */
2936
- skip_bytes = (Py_ssize_t) (self->b2cratio * chars_to_skip);
+ double skip_bytes_d = self->b2cratio * (double) chars_to_skip;
2937
+ if (!(skip_bytes_d >= 0) || skip_bytes_d >= (double) PY_SSIZE_T_MAX) {
2938
+ PyErr_SetString(PyExc_OverflowError,
2939
+ "chars_to_skip are too large");
2940
+ goto fail;
2941
+ }
2942
+ skip_bytes = (Py_ssize_t) skip_bytes_d;
2943
skip_back = 1;
2944
assert(skip_bytes <= PyBytes_GET_SIZE(next_input));
2945
input = PyBytes_AS_STRING(next_input);
0 commit comments