Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Null dereferencing of a pointer in initconfig.c

Open Beginner friendly
#160,962 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@lazerg is already working on this.

Since Oct 30, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c, python

Research direction

Start at the two linked locations in Python/initconfig.c and compare the handling of NULL values with the PyConfig_MEMBER_WSTR_OPT case. Check the C API documentation in Doc/c-api/init_config.rst, then verify that the behavior matches its contract and that the relevant configuration tests pass.

Written by the indexing model from the issue text.

Description

interpreter-core topic-C-API type-bug
Bug report

Potentially, if "value" equals NULL and "spec->type" equals "PyConfig_MEMBER_WSTR_OPT", null will be passed into "utf8_to_wstr" function and might cause a segmentation fault in strlen
https://github.com/python/cpython/blob/d3a1e7280bd74a16c5822cff9c77fa28da4d725e/Python/initconfig.c#L4369-L4376
https://github.com/python/cpython/blob/d3a1e7280bd74a16c5822cff9c77fa28da4d725e/Python/initconfig.c#L4324-L4328

Documentation states that "value" is a null-terminated UTF-8 string, but isn't clearly stating that Null is allowed

Suggested fix: separate "value" and "spec->type" checks

if (value == NULL) { 
        if (spec->type != PyConfig_MEMBER_WSTR_OPT) {
               nitconfig_set_error(config, "config option string cannot be NULL");
               return -1;
               }
    wchar_t **member = raw_member;
    free(*member);
    *member = wstr;
    return 0;
}
CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Dominant language
Python
Stars
77.8k
Forks
37.7k
Avg merge
11h 25m
Merged PRs (30d)
723

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/cpython

All issues in python/cpython

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.