8000 gh-99240: Fix double-free bug in Argument Clinic str_converter generated code by colorfulappl · Pull Request #99241 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

< 8000 bdi class="js-issue-title markdown-title">gh-99240: Fix double-free bug in Argument Clinic str_converter generated code #99241

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Nov 24, 2022
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
Do not generate redundant NULL check
  • Loading branch information
colorfulappl committed Nov 24, 2022
commit aa218c4638bb929f23ed07d42646b1cee860ebcd
22 changes: 6 additions & 16 deletions Lib/test/clinic.test
Original file line number Diff line number Diff line change
Expand Up @@ -1741,25 +1741,15 @@ test_str_converter_encoding(PyObject *module, PyObject *const *args, Py_ssize_t
}
return_value = test_str_converter_encoding_impl(module, a, b, c, d, d_length, e, e_length);
/* Post operation for a */
if (a) {
PyMem_FREE(a);
}
PyMem_FREE(a);
/* Post operation for b */
if (b) {
PyMem_FREE(b);
}
PyMem_FREE(b);
/* Post operation for c */
if (c) {
PyMem_FREE(c);
}
PyMem_FREE(c);
/* Post operation for d */
if (d) {
PyMem_FREE(d);
}
PyMem_FREE(d);
/* Post operation for e */
if (e) {
PyMem_FREE(e);
}
PyMem_FREE(e);

exit:
return return_value;
Expand All @@ -1769,7 +1759,7 @@ static PyObject *
test_str_converter_encoding_impl(PyObject *module, char *a, char *b, char *c,
char *d, Py_ssize_t d_length, char *e,
Py_ssize_t e_length)
/*[clinic end generated code: output=5dfef501bb5f5e82 input=eb4c38e1f898f402]*/
/*[clinic end generated code: output=a9f5b30da7f9bfaf input=eb4c38e1f898f402]*/


/*[clinic input]
Expand Down
22 changes: 6 additions & 16 deletions Modules/clinic/_testclinic.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3440,7 +3440,7 @@ def converter_init(self, *, accept={str}, encoding=None, zeroes=False):
def post_parsing(self):
if self.encoding:
name = self.name
return "".join(["if (", name, ") {\n PyMem_FREE(", name, ");\n}\n"])
return f"PyMem_FREE({name});\n"

def parse_arg(self, argname, displayname):
if self.format_unit == 's':
Expand Down
0