diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2022-09-16 18:52:52 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2022-09-16 18:52:52 +0100 |
commit | c5610fd4b3ff948a0220368f92dd842ef877b3f0 (patch) | |
tree | 1cbd5fcf1d5831ed3732b1e99137598c9bac24e4 /Lib | |
parent | dad7c93ca0a923e7d2671347cee711d180dd0338 (diff) | |
download | swig-c5610fd4b3ff948a0220368f92dd842ef877b3f0.tar.gz |
Guile - Add error checking to SWIGTYPE and SWIGTYPE & in typemaps
To prevent seg faults when passing #nil to these parameter types.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/guile/typemaps.i | 10 |
1 files changed, 8 insertions, 2 deletions
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; } |