This is a very subtle error (took me a lot of time to trace down and finally finding the cause).
If a RexxStringObject has a numeric value like "5" or "80", then StringLength() returns the numeric value of the Rexx string instead of the length of the strings (1 and 2 respectively). Sending the message "length" to the same RexxStringObject will return the correct string lengths:
... cut ... size_t len=context->StringLength(rso); // get length int32_t tmpLength=0; logical_t res=context->ObjectToInt32(context->SendMessage0(rso, "LENGTH"), &tmpLength); ... cut ...
RexxStringObjects having the string value "5" or "80" will yield a value for "len" of 5 or 80, for "tmpLength" the correct values of 1 and 2, respectively.
Again, quite a subtle problem (using StringLength in quite a few places in the external function package BSF4ooRexx and will have to change the code to switch to the message form if running on ooRexx 4.0.1 comparing REXX_CURRENT_INTERPRETER_VERSION against REXX_INTERPRETER_4_0_1).