https://github.com/python/cpython/commit/c6e74311fef6f2597b2d790fb31ade60dd30b3e1 commit: c6e74311fef6f2597b2d790fb31ade60dd30b3e1 branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: StanFromIreland <[email protected]> date: 2026-10-25T18:15:03Z summary:
[3.15] gh-151126: Set `MemoryError` on allocation failure in CJK codec macros (GH-156292) (#160674) (cherry picked from commit d441a118fa8c52630becd75f49f4302c16d1412d) Co-authored-by: Thomas Kowalski <[email protected]> Co-authored-by: Stan Ulbrych <[email protected]> files: A Misc/NEWS.d/next/Library/2026-08-23-16-33-00.gh-issue-151126.GUvtG7.rst M Modules/cjkcodecs/cjkcodecs.h diff --git a/Misc/NEWS.d/next/Library/2026-08-23-16-33-00.gh-issue-151126.GUvtG7.rst b/Misc/NEWS.d/next/Library/2026-08-23-16-33-00.gh-issue-151126.GUvtG7.rst new file mode 100644 index 00000000000000..01a49138469598 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-08-23-16-33-00.gh-issue-151126.GUvtG7.rst @@ -0,0 +1,2 @@ +Fix a crash caused by failing to set :exc:`MemoryError` on allocation +failure when first using a Chinese, Japanese or Korean codec. diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h index 020559ac014b1f..7ae1082b27b408 100644 --- a/Modules/cjkcodecs/cjkcodecs.h +++ b/Modules/cjkcodecs/cjkcodecs.h @@ -237,6 +237,7 @@ add_mappings(cjkcodecs_module_state *st) \ st->num_mappings = NUM; \ st->mapping_list = PyMem_Calloc(NUM, sizeof(struct dbcs_map)); \ if (st->mapping_list == NULL) { \ + PyErr_NoMemory(); \ return -1; \ } @@ -261,6 +262,7 @@ add_codecs(cjkcodecs_module_state *st) \ st->num_codecs = NUM; \ st->codec_list = PyMem_Calloc(NUM, sizeof(MultibyteCodec)); \ if (st->codec_list == NULL) { \ + PyErr_NoMemory(); \ return -1; \ } _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
