10000 gh-123378: fix a crash in `UnicodeError.__str__` by picnixz · Pull Request #124935 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-123378: fix a crash in UnicodeError.__str__ #124935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix Windows compilation
  • Loading branch information
picnixz committed Oct 3, 2024
commit 80287f624058cd3ba13d10208e5a2d9de0883ac0
8 changes: 4 additions & 4 deletions Objects/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -3014,8 +3014,8 @@ UnicodeEncodeError_str(PyObject *self)
}

PyObject *res;
ssize_t len = PyUnicode_GET_LENGTH(exc->object);
ssize_t start = exc->start, end = exc->end;
Py_ssize_t len = PyUnicode_GET_LENGTH(exc->object);
Py_ssize_t start = exc->start, end = exc->end;

if ((start >= 0 && start < len) && (end >= 0 && end <= len) && end == start + 1) {
Py_UCS4 badchar = PyUnicode_ReadChar(exc->object, start);
Expand Down Expand Up @@ -3128,8 +3128,8 @@ UnicodeDecodeError_str(PyObject *self)
}

PyObject *res;
ssize_t len = PyBytes_GET_SIZE(exc->object);
ssize_t start = exc->start, end = exc->end;
Py_ssize_t len = PyBytes_GET_SIZE(exc->object);
Py_ssize_t start = exc->start, end = exc->end;

if ((start >= 0 && start < len) && (end >= 0 && end <= len) && end == start + 1) {
int badbyte = (int)(PyBytes_AS_STRING(exc->object)[start] & 0xff);
Expand Down
Loading
0