Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed
Labels
3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Bug report
Bug description:
Found when implementing #123343. We have:
intPyUnicodeEncodeError_GetStart(PyObject*exc, Py_ssize_t*start){Py_ssize_tsize; PyObject*obj=get_unicode(((PyUnicodeErrorObject*)exc)->object, "object"); if (!obj) return-1; *start= ((PyUnicodeErrorObject*)exc)->start; size=PyUnicode_GET_LENGTH(obj); if (*start<0) *start=0; /*XXX check for values <0*/if (*start>=size) *start=size-1; Py_DECREF(obj); return0}The line *start = size-1 might set start to -1 when start = 0, in which case this leads to assertion failures when the index is used normally.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-123378: fix a crash in
UnicodeError.__str__#124935 - [3.12] gh-123378: fix a crash in
UnicodeError.__str__(GH-124935) #125098 - [3.13] gh-123378: fix a crash in
UnicodeError.__str__(GH-124935) #125099 - gh-123378: fix some corner cases of
startandendvalues inPyUnicodeErrorObject#123380 - gh-123378: fix post-merge typos in comments and NEWS #127739
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Projects
Status
Done