this post was submitted on 11 Oct 2023
6 points (75.0% liked)
Programming
17392 readers
164 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
~~What revision are you using? Because I don't see the
ret = realloc(ptr, 1);
line in https://github.com/torvalds/linux/blob/master/tools/lib/subcmd/subcmd-util.h .~~ (EDIT: my bad, it's in the subcmd-util.h file linked in the other comment)Also, make sure you have the latest version of GCC, because I remember it yielding many false-positives when I was implementing some reference counting (which obviously is prone to false positives in static analysis) and those warnings disappeared after updating the compiler.
EDIT: from the looks of it GCC's "static analysis" basically assumed the worst case (ie that the first realloc is freeing memory and the second one is allocating new memory elsewhere and is copying from the old pointer, thus accessing it and hence the use-after-free warning). You can probably just remove the warning as the others have suggested, or you could try to downgrade GCC to version 11 as many of the search results regarding those use-after-free warnings involve later versions.