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
This commit is contained in:
parent
d115e52bc0
commit
f9393a0f06
2 changed files with 16 additions and 4 deletions
16
Lib/swig.swg
16
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 [] {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue