Fix #1798728 - numbers can be passed to functions taking char *
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10190 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b79ebf39fa
commit
0d799435b8
2 changed files with 13 additions and 1 deletions
12
Examples/test-suite/perl5/char_strings_runme.pl
Normal file
12
Examples/test-suite/perl5/char_strings_runme.pl
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
use char_strings;
|
||||||
|
|
||||||
|
my $val1 = 100;
|
||||||
|
if (char_strings::CharPingPong($val1) != "100") {
|
||||||
|
die "failed";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $val2 = "greetings";
|
||||||
|
if (char_strings::CharPingPong($val2) != "greetings") {
|
||||||
|
die "failed";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
SWIGINTERN int
|
SWIGINTERN int
|
||||||
SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
|
SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
|
||||||
{
|
{
|
||||||
if (SvPOK(obj)) {
|
if (SvOK(obj)) {
|
||||||
STRLEN len = 0;
|
STRLEN len = 0;
|
||||||
char *cstr = SvPV(obj, len);
|
char *cstr = SvPV(obj, len);
|
||||||
size_t size = len + 1;
|
size_t size = len + 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue