- [Lua] Fix off-by-one when nil terminates the table early: use $1 = i
(not i + 1) to match the count of strings actually copied, and pop
the nil from the Lua stack before breaking.
- [Python] In SWIG_AsCharPtrAndSize (pystrings.swg) decref bytes / obj
on the SWIG_MemoryError early returns added by the previous commits,
so an allocation failure no longer leaks the temporary PyObject.
- [Octave, Python] In argcargv.i free already-allocated string entries
and the array itself before failing on a per-element OOM (Python uses
the existing break path so the freearg typemap performs the cleanup).
- [Perl, PHP, Tcl] Drop unreachable `goto fail` after SWIG_croak /
SWIG_PHP_Error / SWIG_exception_fail, all of which already invoke
SWIG_fail. Compilers warning on unreachable code complained.
- Standardise the OOM error wording across languages and fix the
3- and 5-space indentation introduced by the previous commits.
- Update Examples/perl5/xmlstring/xmlstring.i to the new
%typemaps_string signature (it picks up the missing WarningLeakMsg
argument too) and add a SWIG_NewCopyXMLChArray fragment.
- CHANGES.current: document the API breakages introduced by removing
%new_copy_array, removing %typemaps_string_alloc and extending
%typemaps_string, including the actual error text users will see.
Assisted-by: Claude Opus 4.7 <noreply@anthropic.com>
Use the usual C rule for NUL-terminated strings instead of discarding all the
trailing NUL characters.
This was unexpected (as buffers in C code are not necessarily always padded
with NULs to their full length) and also inconsistent among languages as this
was only done for those of them using typemaps/strings.swg but not for C# or
Java, for example, which terminated the string at the first NUL even before
this change.
Notice that this patch couldn't use strlen() or wcslen() with possibly not
NUL-terminated strings, so we had to add [our own equivalents of] strnlen()
and wcsnlen() and use them instead. This required adding yet another parameter
to string typemap macros, so update the example using them accordingly too.