Repository navigation
cups-browsed: fix cppcheck 2.19 findings - #87
Merged
Merged
Conversation
The cppcheck job has been failing since ubuntu-latest moved to Ubuntu 26.04, which ships cppcheck 2.19 instead of 2.13. It reports 20 findings on master: - nullPointerRedundantCheck for type/domain in create_remote_printer_entry() and examine_discovered_printer_record(). Both functions already return early when type or domain is NULL, so the later "!= NULL" checks are redundant; remove them. - nullPointerOutOfMemory for unchecked malloc()/calloc()/strdup() results in update_cups_queues(), get_cluster_default_attributes(), remove_bad_chars() and read_browseallow_value(). Check them and bail out the same way the surrounding code handles other errors. - memleak: when no queue-creation thread can be started after all retries, the create_args_t was freed but its queue and uri strings were not. Free them too. With this, cppcheck 2.19 (same options as the CI job) reports nothing. The build and "make check" still pass.
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cppcheck job has been failing on master since 2026-11-18. No code change caused it:
ubuntu-latestmoved to Ubuntu 26.04, which installs cppcheck 2.19 instead of 2.13 (compare the "Setting up cppcheck" line in the runs for 2869a8b and 4aa6023). The newer version reports 20 findings on master.type/domain) increate_remote_printer_entry()andexamine_discovered_printer_record(). Both functions already return early whentypeordomainis NULL, so the later!= NULLchecks are redundant. Removed them, which leaves the[0] != '\0'checks.malloc()/calloc()/strdup()inupdate_cups_queues(),get_cluster_default_attributes(),remove_bad_chars()andread_browseallow_value(). Each now bails out the way the surrounding code handles other errors. Inupdate_cups_queues()the queue simply staysSTATUS_TO_BE_CREATEDand is retried on the next pass.create_args_twas freed but itsqueueanduristrings were not. That's a real (small) leak, and this PR fixes it.I didn't pin the runner back to 24.04, because that would only hide the findings.
Testing: in an
ubuntu:26.04container with the exact cppcheck command from.github/workflows/cppcheck.yml, master exits 1 with 20 findings and this branch exits 0 with none. The build succeeds andmake checkpasses (non-root, D-Bus + Avahi up).