Conversation
Even though we are using with GNU extensions I will add this flag since I prefer the explicit writing style that we have to use wich this flag enabled.
Adding an explicit NULL check for 'input' at the start of cmd_ac_complete to prevent a potential crash and resolve a GCC static analyzer warning. Quirk Explanation: The analyzer found a "deref-before-check" warning for: `if ((strncmp(input, "/", 1) == 0) && (!strchr(input, ' ')))` The analyzer interpreted 'strchr(input, ' ')' as a point where the validity of 'input' is being questioned (a "check"), even though it is actually checking the return value. This is due to GCC's internal model of certain standard string functions having a 'nonnull' attribute or being categorized as pointer "interrogations" in its state machine. Because 'strncmp' dereferences 'input' earlier in the same line, the analyzer saw a logical contradiction: "You treat it as safe in strncmp, but then you call a function (strchr) that 'requires/checks' it to be safe, implying you weren't sure."
Let's add an explicit check.
Simplify how field values are updated and ensure memory is correctly managed. The previous implementation relied on manual manipulation of the GSList internal `data` member and only handled cases where a field had zero or one existing value. The function now correctly handles fields that may already contain multiple values by using 'g_slist_free_full' to clear the entire list and its contents before setting the new value.
Should help us find the following bugs early. ASan: * Out-of-bounds accesses * Use-after-free * Memory leaks * Double free / Invalid free UBSan: * Undefined Behavior * Signed integer overflow * Null pointer dereference * Pointer misalignment * Division by zero * Bit-shifting out of bounds This needs works during runtime. But let's add it here so that at least basic --version run is test and as a reminder for developer to add it. I will also adjust documentation later on.
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.
No description provided.