Fix undefined behaviour in samtools fastq with empty QUAL.#2084
Merged
Conversation
Incrementing via "qt_end += qt != NULL" will be qt_end+=0 when we have
a null qt/qt_end, but NULL+0 is technically undefined.
bam_fastq.c:852:30: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior bam_fastq.c:852:30 in
Easy to just replace with two loops and avoid such cleverness. It's
not a major portability issue, but it's nice to have no warnings from
ubsan as it makes finding other problems easier.
Member
|
Change looks OK, but is |
Contributor
Author
|
Possibly not, but my aim wasn't so much to be 100% anal on the rules if they're not triggering problems and instead to simply get to a point where -fsanitize=undefined triggers no errors and could become part of the CI system (with appropriate envs to make it fail on error). If other code subsequently starts to trigger issues, then the CI would notify us and we can fix it, but too much naval gazing isn't really productive when something is working. |
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.
Incrementing via "qt_end += qt != NULL" will be qt_end+=0 when we have a null qt/qt_end, but NULL+0 is technically undefined.
Easy to just replace with two loops and avoid such cleverness. It's not a major portability issue, but it's nice to have no warnings from ubsan as it makes finding other problems easier.