Remove Undefined Behavior in ISFS Example#28
Merged
DacoTaco merged 2 commits intodevkitPro:masterfrom Aug 4, 2025
Merged
Conversation
Undefined behavior was causing crashes in isfs.c, because specific values were expected to by 0 but had the chance to not be
DacoTaco
reviewed
Aug 3, 2025
| @@ -357,6 +357,8 @@ int main(int argc, char** argv) { | |||
| DIR_ENTRY parent; | |||
Member
There was a problem hiding this comment.
i think a better fix would be to init the struct with zeroes. this can be done by doing DIR_ENTRY parent = {0} or DIR_ENTRY parent = {}. then you wouldn't need to go over all variables and set them to zero :)
Contributor
Author
There was a problem hiding this comment.
Sounds good to me ^^
Initializing the entire struct with 0 removes any possibility of *future* UB as well hopefully, or at least makes sure nothing was missed, while generally being more concise ^^;
DacoTaco
approved these changes
Aug 4, 2025
Member
DacoTaco
left a comment
There was a problem hiding this comment.
lgtm, thanks for your contribution!
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.
Undefined behavior was causing crashes in isfs.c, because specific values on the initial directory read from were expected to by 0 but had the chance to not be
Specifically, with the initial directory that gets read, the children pointer may not have been
NULL, leading toAddChildEntryassuming there was already allocated data, andsizecould've been nonzero, leading it to assume the total number of children had already been requested (although likely with no effect on the example program itself)