From e48967cd0d29a71cd2cf8881ebdcf85f7dc296fb Mon Sep 17 00:00:00 2001 From: Brett Lawson Date: Mon, 26 Oct 2026 10:17:00 +0100 Subject: [PATCH] Narrow fillet_corner_p3 null-curve guard and check curve count first The shim no longer refuses a corner edge without a 3D curve: upstream CreateCornerBlend returns SM_ERR below four curves and otherwise SM_ERR_NULL_POINTER, without crashing. create_corner_patch now checks the count before dereferencing curves, matching that order. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_011gJAwcLRBPQXYLmvXd3pWf --- crates/solidcore/src/blend/fillet_corner/p3.rs | 7 +++++++ harness/cpp/shim/blend_fillet_corner_p3_static.inc | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/solidcore/src/blend/fillet_corner/p3.rs b/crates/solidcore/src/blend/fillet_corner/p3.rs index 3c39331c1d..ebc51cf2e3 100644 --- a/crates/solidcore/src/blend/fillet_corner/p3.rs +++ b/crates/solidcore/src/blend/fillet_corner/p3.rs @@ -1479,6 +1479,13 @@ impl FilletCorner { let _ = total_edges; // build the corner patch from the ordered array boundary information + // CreateCornerBlend checks `cr3DCurves.GetSize() < 4 -> SM_ERR` before it + // touches any curve (a null one is SM_ERR_NULL_POINTER afterwards). + if ordered_3d.len() < 4 { + return Err(SolidError::sm_err( + "nurbs::b_spline_surface_n_lib::p2::BSplineSurface::create_corner_blend", + )); + } let mut curves_3d = Vec::with_capacity(ordered_3d.len()); for c in &ordered_3d { let c = c diff --git a/harness/cpp/shim/blend_fillet_corner_p3_static.inc b/harness/cpp/shim/blend_fillet_corner_p3_static.inc index 0d3cb58a42..423d43eb1d 100644 --- a/harness/cpp/shim/blend_fillet_corner_p3_static.inc +++ b/harness/cpp/shim/blend_fillet_corner_p3_static.inc @@ -587,8 +587,8 @@ double p3_check_default_patch(SmFilletCorner* c, const std::vectorGetCurve(); - if (curve == NULL) - return P3C_REFUSE; // CreateCornerBlend reads every boundary curve + // A NULL curve is not refused: CreateCornerBlend returns SM_ERR below four curves, + // else sm_CreateNonRationalCurve casts null-safely and returns SM_ERR_NULL_POINTER. uv.Add(ps); c3d.Add(curve); orients.Add(SM_OT_SAME);