Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-107954, PEP 741: Add PyInitConfig C API #123502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix leak in PyInitConfig_GetStrList()
+ some extra edits
  • Loading branch information
vstinner committed Sep 2, 2024
commit 7e3e1aa52b94e804f6b07efb86d4c8328f1ceeca
3 changes: 3 additions & 0 deletions 3 Doc/c-api/init_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,9 @@ null-terminated UTF-8 encoded string.
* Set *\*value*, and return ``0`` on success.
* Set an error in *config* and return ``-1`` on error.

*\*value* can be set to ``NULL`` if the option is an optional string and the
option is unset.

On success, the string must be released with ``free(value)``.


Expand Down
5 changes: 3 additions & 2 deletions 5 Python/initconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -3631,7 +3631,8 @@ PyInitConfig_GetStr(PyInitConfig *config, const char *name, char **value)
}

if (spec->type != PyConfig_MEMBER_WSTR
&& spec->type != PyConfig_MEMBER_WSTR_OPT) {
&& spec->type != PyConfig_MEMBER_WSTR_OPT)
{
initconfig_set_error(config, "config option type is not string");
return -1;
}
Expand Down Expand Up @@ -3676,7 +3677,7 @@ PyInitConfig_GetStrList(PyInitConfig *config, const char *name, size_t *length,
for (Py_ssize_t i=0; i < list->length; i++) {
(*items)[i] = wstr_to_utf8(config, list->items[i]);
if ((*items)[i] == NULL) {
free(*items);
PyInitConfig_FreeStrList(i, *items);
return -1;
}
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.