Skip to content

test_initconfig_get_api fails on platforms where malloc(0) returns NULL #153691

Description

@zuhu2195

Bug report

Bug description:

test_initconfig_get_api (Programs/_testembed.c) executes the code

    assert(PyInitConfig_GetStrList(config, "xoptions", &length, &items) == 0);
    assert(length == 0);

PyInitConfig_GetStrList has malloc

*items = malloc(list->length * sizeof(char*));

if length is zero the behavior of malloc(0) is implementation defined, this seems to be problematic on platforms where malloc of zero returns NULL.

CPython versions tested on:

3.14

Operating systems tested on:

Other

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions