Bug 202977
Summary: | newlocale(3) double free in example | ||
---|---|---|---|
Product: | Documentation | Reporter: | piotr |
Component: | man-pages | Assignee: | documentation_man-pages (documentation_man-pages) |
Status: | RESOLVED CODE_FIX | ||
Severity: | normal | CC: | mtk.manpages |
Priority: | P1 | ||
Hardware: | All | ||
OS: | Linux | ||
Kernel Version: | Subsystem: | ||
Regression: | No | Bisected commit-id: |
Description
piotr
2019-03-20 19:30:14 UTC
FWIW if the same test is run in a thread one will need to call freelocale. Maybe the locale should be changed before it's freed. Maybe the cleanup code should look as follows: uselocale(LC_GLOBAL_HANDLE); freelocale(loc); exit(EXIT_SUCCESS); (In reply to piotr from comment #1) > FWIW if the same test is run in a thread one will need to call freelocale. > Maybe the locale should be changed before it's freed. Maybe the cleanup code > should look as follows: > uselocale(LC_GLOBAL_HANDLE); > freelocale(loc); > > exit(EXIT_SUCCESS); Thanks for the report and that further info. It looks like you are correct. Grepping the Fedora package source code, I see a number of instances of that pattern. I applied the patch below. Closing this report now. --- a/man3/newlocale.3 +++ b/man3/newlocale.3 @@ -366,6 +366,7 @@ main(int argc, char *argv[]) /* Free the locale object */ + uselocale(LC_GLOBAL_HANDLE); /* So 'loc' is no longer in use */ freelocale(loc); exit(EXIT_SUCCESS); |