Initialise two members that are read before they are written - #486
Open
attixray wants to merge 2 commits into
Open
Initialise two members that are read before they are written#486attixray wants to merge 2 commits into
attixray wants to merge 2 commits into
Conversation
added 2 commits
August 21, 2026 19:50
STEPnode::_null had no default: STEPnode has no constructor, so a node built by a subclass that does not assign it starts out with whatever was on the heap, and is_null() then answers at random. Give STEPnode a constructor that starts nodes null. EntityNode::StrToVal() and ::STEPread() additionally have to set it per outcome - they resolve an entity reference and must report null exactly when the reference did not resolve. Before this, a node whose reference failed to resolve could still report itself non-null.
_altname is a char[BUFSIZ+1] that neither constructor touches, so CurrName() and the AltNameOf paths can read uninitialised heap until something calls AltName(). Start it empty.
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.
Two independent uninitialised reads, both long-standing.
STEPnode::_nullhas no default.STEPnodehas no constructor, so a node built by a subclass that does not assign it starts out with whatever was on the heap, andis_null()then answers at random. This adds aSTEPnodeconstructor that starts nodes null, and makesEntityNode::StrToVal()/::STEPread()set it per outcome — they resolve an entity reference and should report null exactly when the reference did not resolve.TypeDescriptor::_altnameis achar _altname[BUFSIZ+1]that both constructors leave untouched, whileAltName()and theName()fallback read it as a C string. Terminating it on construction makes the "no alternate name" case deterministic.Two commits, one per member.