Skip to content
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

Use after free warning #411

Open
N-R-K opened this issue Nov 7, 2022 · 0 comments
Open

Use after free warning #411

N-R-K opened this issue Nov 7, 2022 · 0 comments

Comments

@N-R-K
Copy link

N-R-K commented Nov 7, 2022

The following warning is emitted when trying to compile on gcc 12.1.1:

xdo.c: In function 'xdo_get_active_modifiers':
xdo.c:1664:17: warning: pointer 'keys' used after 'realloc' [-Wuse-after-free]
 1664 |           *keys = realloc(keys, keys_size * sizeof(charcodemap_t));
      |           ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xdo.c:1664:19: note: call to 'realloc' here
 1664 |           *keys = realloc(keys, keys_size * sizeof(charcodemap_t));
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

xdotool/xdo.c

Line 1664 in df94eb6

*keys = realloc(keys, keys_size * sizeof(charcodemap_t));

It appears to me that it should've been realloc(*keys, ...) and not realloc(keys, ...). (And even that would incorrect as that assumes that realloc always succeeds).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant