Modeling Data - Fix GeomTools_Curve2dSet/SurfaceSet null-handle Add()/Index() divergence from CurveSet - #1435
Open
gsdali wants to merge 1 commit into
Conversation
1 task
Member
|
Dear @gsdali please add GTest to cover your changes, you can follow the logic of all exited GTests. |
…ex null-handle handling GeomTools_CurveSet::Add already guards a null Handle(Geom_Curve) and drops it (returns 0). GeomTools_Curve2dSet::Add and GeomTools_SurfaceSet::Add do not: they accept the null and return a valid-looking index, then Write() derefs it unconditionally and crashes. Index() has the identical divergence (no crash, but a bogus non-zero index for a handle that was never really bound). Matches the sibling that is already correct. Tests: added GeomTools_Curve2dSet_Test.cxx and GeomTools_SurfaceSet_Test.cxx in src/ModelingData/TKGeomBase/GTests/, covering Add()/Index() with a null handle (must be dropped/return 0, matching GeomTools_CurveSet), Write() after adding a null (must not crash), and a valid-handle case as a control. Verified both ways: against the current pinned kernel (predates this fix), Add(null) returns 1 (should be 0) and Write() SIGSEGVs; linked with the patched translation units ahead of the archive, all 8 tests pass.
gsdali
force-pushed
the
fix/geomtools-curve2dset-surfaceset-null-handle-add-index
branch
from
August 11, 2026 00:00
b683221 to
db31ec1
Compare
Contributor
Author
|
Thanks — pushed GTests.
|
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.
Description of the change
GeomTools_CurveSet::Addguards a nullHandle(Geom_Curve)and drops it (return (C.IsNull()) ? 0 : myMap.Add(C);).GeomTools_Curve2dSet::AddandGeomTools_SurfaceSet::Adddo not: they acceptthe null and hand back a valid-looking index, which later crashes
Write()when it dereferences thehandle it was never checked against.
Index()has the identical divergence one function down(
CurveSet::Indexguards, the other two do not) — it does not crash, sinceNCollection_IndexedMap::FindIndexonly hashes/compares the handle's identity, but it silentlyreturns a bogus non-zero index for a handle that was never validly bound.
Adds the same guard
CurveSet::Add/CurveSet::Indexalready have, to both methods on both siblingclasses — four one-line changes, matching the correct sibling rather than introducing a new pattern:
Related issue
Fixes #1434.
Type of change
How Has This Been Tested?
Add(nullHandle)thenWrite()onGeomTools_Curve2dSetand
GeomTools_SurfaceSetSIGSEGVs on stockmaster/V8_0_1;GeomTools_CurveSetdoes not,since its
Add()already drops the null.static archive, so the linker resolves these two TUs' symbols from the override): before the
patch,
Curve2dSet/SurfaceSetboth accept the null (Addreturns 1) and SIGSEGV inWrite();after, all three classes'
Add()return 0 andWrite()completes normally on all three.Index()before the patch returns the same bogus 1 forCurve2dSet/SurfaceSetafter adding anull handle; after, all three classes'
Index()return 0, matchingCurveSet::Index.Add/Index/Write/Readbehavior for non-null handles is untouched by this change (the new branch is only taken when
IsNull()is true).Checklist:
mirror
GeomTools_CurveSet's own existing, uncommented idiom line for line"does not crash, and reports the same index CurveSet already reports for a null handle"
wrapper project (OCCTSwift), which found this crash through a null-handle-guard census; happy
to add a GTest if maintainers point me at the right fixture convention for this area