Added check for nil object being passed to SWIG_AsCharPtrAndSize. If a nil object is passed in then an error is returned.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8416 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
54e7622a05
commit
237d452aba
1 changed files with 4 additions and 1 deletions
|
|
@ -6,7 +6,10 @@
|
||||||
SWIGINTERN int
|
SWIGINTERN int
|
||||||
SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)
|
SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)
|
||||||
{
|
{
|
||||||
if (TYPE(obj) == T_STRING) {
|
/* Check for nil object first */
|
||||||
|
if (obj == Qnil) {
|
||||||
|
return SWIG_BADOBJ;
|
||||||
|
} else if (TYPE(obj) == T_STRING) {
|
||||||
char *cstr = rb_string_value_ptr(&(obj));
|
char *cstr = rb_string_value_ptr(&(obj));
|
||||||
size_t size = RSTRING(obj)->len + 1;
|
size_t size = RSTRING(obj)->len + 1;
|
||||||
if (cptr) {
|
if (cptr) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue