You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Harden argument validation across MEX commands (complex, spars
8F2F
e, fractional, out-of-range input) #21
While reviewing PR #20 (QuerySubBlockDirectory), automated review showed that argument validation in the existing MEX commands is not strict enough. The new command was hardened on its own. The shared helpers and the older commands were deliberately left unchanged to keep that PR focused.
Problems
Complex arrays are not rejected. They reach mxGetDoubles and similar calls, which abort the whole MEX call instead of raising a catchable error. Fixing this needs a new pfn_IsComplex in the app-extension API (MATLAB, Octave and the function table).
Sparse arrays are not rejected consistently by the existing commands.
Fractional values:CArgsUtils::TryGetInt32 rounds floating-point input via lrint. For example, 0.5 or 1.7 is silently accepted as an integer.
Out-of-range values: floating-point input at or beyond the int32 limits is not rejected. For example, single(2147483648) is accepted because of float rounding at INT_MAX.
Unsupported classes:TryGetInt32 does not handle the logical class.
Helpers built on TryGetInt32 inherit these problems, including TryGetIntRect.
Proposed work
Add pfn_IsComplex to the app API, and reject complex input wherever numeric arguments are read.
Make the shared integer helpers strict. They should reject fractional, non-finite and out-of-range values, and handle the logical class explicitly.
Apply sparse and complex checks consistently in every command's CheckArguments.
Add MATLAB and Octave tests for each rejection case.
Reference
QuerySubBlockDirectory (PR #20) already contains the stricter validation, e.g. TryGetIntegralInt32 in lib/src/functions/func_querysubblockdirectory.cpp. It can serve as a model, or be refactored into the shared helpers.
Activity