Skip to content

NetBSD compile warning ("potential null pointer dereference") #1662

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

Open
Explorer09 opened this issue Apr 6, 2025 · 4 comments
Open

NetBSD compile warning ("potential null pointer dereference") #1662

Explorer09 opened this issue Apr 6, 2025 · 4 comments
Labels
code quality ♻️ Code quality enhancement NetBSD 🎏 NetBSD related issues

Comments

@Explorer09
Copy link
Contributor

Explorer09 commented Apr 6, 2025

This warning is when building htop for NetBSD, with GCC with -flto enabled

lto-wrapper: warning: using serial compilation of 3 LTRANS jobs
DisplayOptionsPanel.c: In function ‘DisplayOptionsPanel_eventHandler’:
DisplayOptionsPanel.c:98:14: error: potential null pointer dereference [-Werror=null-dereference]
   98 |          if (OptionItem_kind(selected) == OPTION_ITEM_NUMBER) {
      |              ^
lto1: all warnings being treated as errors
lto-wrapper: fatal error: gcc returned 1 exit status

I actually caught this one in CI (build log), and yet I don't know how to fix it at the moment.

@BenBE
Copy link
Member

BenBE commented Apr 6, 2025

NetBSD or OpenBSD?

@BenBE BenBE added code quality ♻️ Code quality enhancement NetBSD 🎏 NetBSD related issues labels Apr 6, 2025
@Explorer09
Copy link
Contributor Author

@BenBE Sorry, it's NetBSD, not OpenBSD. I corrected the description.

@BenBE
Copy link
Member

BenBE commented Apr 6, 2025

The problem is likely selected == NULL, which can be returned from Panel_getSelected(super); in line 91, propagating to line 98 through the fall-thru case …

Modifying line 92 to read if (previous != selected || !selected) { should address this. /untested

@BenBE
Copy link
Member

BenBE commented Apr 22, 2025

@Explorer09 Can you take a look at this suggestion and do a PR if you like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality ♻️ Code quality enhancement NetBSD 🎏 NetBSD related issues
Projects
None yet
Development

No branches or pull requests

4 participants
@BenBE @Explorer09 and others