diff options
-rw-r--r-- | CHANGES.current | 4 | ||||
-rw-r--r-- | Lib/guile/typemaps.i | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/CHANGES.current b/CHANGES.current index d18afadd1..dd808d37f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2022-09-17: wsfulton + [Guile] Add error checking to SWIGTYPE and SWIGTYPE & in typemaps to prevent + seg faults when passing #nil to these parameter types. + 2022-09-16: wsfulton #999 Provide SWIGTYPE MOVE typemaps in swigmove.i for implementing full move semantics when passing parameters by value. diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i index 37dfaee64..45a2208f2 100644 --- a/Lib/guile/typemaps.i +++ b/Lib/guile/typemaps.i @@ -14,9 +14,14 @@ /* Pointers */ -%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { +%typemap(in) SWIGTYPE *, SWIGTYPE [] { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0); } +%typemap(in) SWIGTYPE & ($1_ltype argp) { + argp = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0); + if (!argp) { %argument_nullref("$1_type", $symname, $argnum); } + $1 = argp; +} %typemap(in, noblock=1, fragment="<memory>") SWIGTYPE && (void *argp = 0, int res = 0, std::unique_ptr<$*1_ltype> rvrdeleter) { res = SWIG_ConvertPtr($input, &argp, $descriptor, SWIG_POINTER_RELEASE); if (!SWIG_IsOK(res)) { @@ -136,8 +141,9 @@ /* Pass-by-value */ -%typemap(in) SWIGTYPE($&1_ltype argp) { +%typemap(in) SWIGTYPE ($&1_ltype argp) { argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, $argnum, 0); + if (!argp) { %argument_nullref("$1_type", $symname, $argnum); } $1 = *argp; } |