cpython/Objects
Matt Wozniski c37599200f
gh-151297: Fix undefined behavior in _PyObject_MiRealloc (GH-151358)
The standard says that a call to `memcpy` must pass a valid source and
destination pointer even if the size is 0, so we must avoid calling
`memcpy` when our source pointer is NULL. If we don't, an optimizing
compiler can decide that the pointer must be non-NULL based on the
presence of UB, and optimize out checks for null pointers.

Specifically, note that the standard says:

    Where an argument declared as size_t n specifies the length of the
    array for a function, n can have the value zero on a call to that
    function. Unless explicitly stated otherwise in the description of
    a particular function in this subclause, pointer arguments on such
    a call shall still have valid values, as described in 7.1.4.

And section 7.1.4 says:

    If an argument to a function has an invalid value (such as a value
    outside the domain of the function, or a pointer outside the address
    space of the program, or a null pointer, or a pointer to
    non-modifiable storage when the corresponding parameter is not
    const-qualified) or a type (after default argument promotion) not
    expected by a function with a variable number of arguments, the
    behavior is undefined.

The specification for `memcpy` doesn't state that it's allowed to be
called with null pointers, and Linux's `/usr/include/string.h` declares
`memcpy` as `__nonnull ((1, 2))`.
2026-06-11 21:21:04 -04:00
..
clinic gh-144774: Add critical section in BaseException.__setstate__ (#150578) 2026-05-30 21:07:27 +05:30
mimalloc gh-151065: Copy fix for memory leak from mimalloc upstream (GH-151066) 2026-06-11 18:11:52 -04:00
stringlib gh-151295: Fix use-after-free in bytes.join()/bytearray.join() via re-entrant __buffer__ (GH-151296) 2026-06-11 07:51:43 +00:00
abstract.c GH-143732: SEND specialization (GH-148963) 2026-05-05 15:19:16 +01:00
boolobject.c gh-111178: remove redundant casts for functions with correct signatures (#131673) 2025-04-01 17:18:11 +02:00
bytearrayobject.c gh-150285: Fix too long docstrings in builtins (GH-150293) 2026-05-24 15:03:32 +03:00
bytes_methods.c gh-150285: Fix too long docstrings in builtins (GH-150293) 2026-05-24 15:03:32 +03:00
bytesobject.c gh-150285: Fix too long docstrings in builtins (GH-150293) 2026-05-24 15:03:32 +03:00
call.c gh-145779: Improve classmethod/staticmethod scaling in free-threaded build (#145826) 2026-03-17 14:24:44 -04:00
capsule.c gh-111178: fix UBSan failures in Objects/capsule.c (GH-128239) 2025-01-08 14:55:04 +01:00
cellobject.c gh-127271: Replace use of PyCell_GET/SET (gh-127272) 2024-12-03 10:33:06 -08:00
classobject.c gh-145779: Improve classmethod/staticmethod scaling in free-threaded build (#145826) 2026-03-17 14:24:44 -04:00
codeobject.c gh-150285: Fix too long docstrings in builtins (GH-150293) 2026-05-24 15:03:32 +03:00
complexobject.c gh-141004: soft-deprecate Py_INFINITY macro (#141033) 2025-11-12 13:44:49 +01:00
descrobject.c gh-150319: Replace all documentation which says "See PEP 585" (#150325) 2026-06-02 21:13:34 +01:00
dictnotes.txt bpo-46845: Reduce dict size when all keys are Unicode (GH-31564) 2022-03-02 08:09:28 +09:00
dictobject.c gh-150490: Raise PyType_Modified for insertion into split dictionary (#150489) 2026-06-11 09:38:31 -07:00
enumobject.c gh-150319: Replace all documentation which says "See PEP 585" (#150325) 2026-06-02 21:13:34 +01:00
exceptions.c gh-150988: Fix refleak in OSError when attrs are set before super().__init__() (#150990) 2026-06-10 12:27:11 +00:00
fileobject.c gh-130821: Add type information to error messages for invalid return type (GH-130835) 2025-08-14 11:04:41 +03:00
floatobject.c gh-150285: Fix too long docstrings in builtins (GH-150293) 2026-05-24 15:03:32 +03:00
frameobject.c gh-150942: Speed up frame local item collection (gh-151002) 2026-06-07 21:05:53 +09:00
funcobject.c gh-146261: JIT: protect against function version changes (#146300) 2026-04-13 02:23:47 +08:00
genericaliasobject.c gh-150285: Fix too long docstrings in GenericAlias and __class_getitem__ (GH-151354) 2026-06-11 19:52:58 +03:00
genobject.c gh-150319: Replace all documentation which says "See PEP 585" (#150325) 2026-06-02 21:13:34 +01:00
interpolationobject.c gh-150319: Replace all documentation which says "See PEP 585" (#150325) 2026-06-02 21:13:34 +01:00
iterobject.c gh-130821: Add type information to error messages for invalid return type (GH-130835) 2025-08-14 11:04:41 +03:00
lazyimportobject.c PEP 810 - Update some error strings (#150126) 2026-05-20 00:47:44 +00:00
listobject.c gh-150319: Replace all documentation which says "See PEP 585" (#150325) 2026-06-02 21:13:34 +01:00
listsort.txt gh-135551: Change how sorting picks minimum run length (#135553) 2025-06-26 23:48:05 -05:00
longobject.c gh-150285: Fix too long docstrings in builtins (GH-150293) 2026-05-24 15:03:32 +03:00
memoryobject.c gh-150319: Replace all documentation which says "See PEP 585" (#150325) 2026-06-02 21:13:34 +01:00
methodobject.c gh-135607: remove null checking of weakref list in dealloc of extension modules and objects (#135614) 2025-06-30 11:14:31 +00:00
moduleobject.c gh-150052: Resolve un-loaded lazily loaded submodules via module.__getattr__ instead of publishing lazy values (#150055) (#150744) 2026-06-02 09:58:51 +01:00
namespaceobject.c gh-143636: fix a crash when calling `__replace__ on invalid SimpleNamespace` instances (#143655) 2026-03-14 09:58:15 +00:00
object.c gh-123619: Fix PyUnstable_Object_EnableDeferredRefcount() (#151260) 2026-06-11 12:55:13 +02:00
object_layout.md GH-115776: Allow any fixed sized object to have inline values (GH-123192) 2024-08-21 15:52:04 +01:00
object_layout_312.gv GH-115776: Embed the values array into the object, for "normal" Python objects. (GH-116115) 2024-04-02 11:59:21 +01:00
object_layout_312.png gh-71648: Optimize PNG files (GH-138842) 2025-09-12 20:13:05 +00:00
object_layout_313.gv GH-115776: Embed the values array into the object, for "normal" Python objects. (GH-116115) 2024-04-02 11:59:21 +01:00
object_layout_313.png gh-71648: Optimize PNG files (GH-138842) 2025-09-12 20:13:05 +00:00
object_layout_full_312.gv GH-96068: Document object layout (GH-96069) 2022-08-23 13:55:43 +01:00
object_layout_full_312.png gh-71648: Optimize PNG files (GH-138842) 2025-09-12 20:13:05 +00:00
object_layout_full_313.gv GH-115776: Embed the values array into the object, for "normal" Python objects. (GH-116115) 2024-04-02 11:59:21 +01:00
object_layout_full_313.png gh-71648: Optimize PNG files (GH-138842) 2025-09-12 20:13:05 +00:00
obmalloc.c gh-151297: Fix undefined behavior in _PyObject_MiRealloc (GH-151358) 2026-06-11 21:21:04 -04:00
odictobject.c gh-150285: Fix too long docstrings in builtins (GH-150293) 2026-05-24 15:03:32 +03:00
picklebufobject.c gh-135607: remove null checking of weakref list in dealloc of extension modules and objects (#135614) 2025-06-30 11:14:31 +00:00
rangeobject.c gh-129068: Make range iterators thread-safe (gh-142886) 2025-12-18 13:11:51 -05:00
README Issue #18093: Factor out the programs that embed the runtime 2014-07-25 21:52:14 +10:00
sentinelobject.c gh-148829: Make sentinels' repr and module customizable (#149654) 2026-05-19 09:18:56 -07:00
setobject.c gh-150319: Replace all documentation which says "See PEP 585" (#150325) 2026-06-02 21:13:34 +01:00
sliceobject.c gh-150319: Replace all documentation which says "See PEP 585" (#150325) 2026-06-02 21:13:34 +01:00
structseq.c gh-148119: Refactor get_type_attr_as_size to improve error handling in structseq.c (#148120) 2026-04-06 17:41:30 +05:30
templateobject.c gh-150319: Replace all documentation which says "See PEP 585" (#150325) 2026-06-02 21:13:34 +01:00
tupleobject.c gh-150285: Fix too long docstrings in GenericAlias and __class_getitem__ (GH-151354) 2026-06-11 19:52:58 +03:00
typeobject.c gh-150490: Raise PyType_Modified for insertion into split dictionary (#150489) 2026-06-11 09:38:31 -07:00
typevarobject.c gh-150285: Fix too long docstrings in GenericAlias and __class_getitem__ (GH-151354) 2026-06-11 19:52:58 +03:00
unicode_format.c gh-142037: Improve error messages for printf-style formatting (GH-142081) 2026-01-24 11:13:50 +00:00
unicode_formatter.c gh-139353: Rename formatter_unicode.c to unicode_formatter.c (#139723) 2025-10-08 14:56:00 +02:00
unicode_writer.c gh-146196: Fix Undefined Behavior in _PyUnicodeWriter_WriteASCIIString() (#146201) 2026-03-20 15:58:41 +00:00
unicodectype.c gh-129117: Add unicodedata.isxidstart() function (#140269) 2025-10-30 10:18:12 +00:00
unicodeobject.c gh-150285: Fix too long docstrings in builtins (GH-150293) 2026-05-24 15:03:32 +03:00
unicodetype_db.h closes gh-138706: update Unicode to 17.0.0 (#138719) 2025-09-11 09:58:39 -07:00
unionobject.c gh-150319: Replace all documentation which says "See PEP 585" (#150325) 2026-06-02 21:13:34 +01:00
weakrefobject.c gh-80384: Check that callback is callable at weak reference creation (GH-151145) 2026-06-10 13:34:55 +03:00

Source files for various builtin objects