diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2008-12-21 00:29:48 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2008-12-21 00:29:48 +0000 |
commit | f9393a0f06b0a79f0d09bee603f2e191741dda4b (patch) | |
tree | b2241ba54dd0c226ef7ccb17883abffb830ace6a | |
parent | d115e52bc03d9185f60f16e53e3968c133af2d2e (diff) | |
download | swig-f9393a0f06b0a79f0d09bee603f2e191741dda4b.tar.gz |
Apply patch #2440046 which fixes possible seg faults for member and global variable char arrays when the strings are larger than the string array size.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10994 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r-- | CHANGES.current | 4 | ||||
-rw-r--r-- | Lib/swig.swg | 16 |
2 files changed, 16 insertions, 4 deletions
diff --git a/CHANGES.current b/CHANGES.current index 27118706c..53406ea98 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (in progress) ============================ +2008-12-21: wsfulton + Apply patch #2440046 which fixes possible seg faults for member and global + variable char arrays when the strings are larger than the string array size. + 2008-12-20: wsfulton The ccache compiler cache has been adapted to work with SWIG and named ccache-swig. It now works with C/C++ compilers as well as SWIG diff --git a/Lib/swig.swg b/Lib/swig.swg index 6f40a8fe9..d5e32b874 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -423,13 +423,21 @@ namespace std { /* Character array handling */ %typemap(memberin) char [ANY] { - if ($input) strncpy((char *)$1, (const char *)$input, $1_dim0); - else $1[0] = 0; + if($input) { + strncpy((char*)$1, (const char *)$input, $1_dim0-1); + $1[$1_dim0-1] = 0; + } else { + $1[0] = 0; + } } %typemap(globalin) char [ANY] { - if ($input) strncpy((char *)$1, (const char *)$input, $1_dim0); - else $1[0] = 0; + if($input) { + strncpy((char*)$1, (const char *)$input, $1_dim0-1); + $1[$1_dim0-1] = 0; + } else { + $1[0] = 0; + } } %typemap(memberin) char [] { |