--- trunk/Lib/perl5/perlrun.swg 2011/05/19 18:48:57 12690 +++ trunk/Lib/perl5/perlrun.swg 2011/05/19 19:31:39 12691 @@ -274,8 +274,14 @@ return SWIG_OK; } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ if (!SvROK(sv)) { - *(ptr) = (void *) 0; - return SWIG_OK; + /* In Perl 5.12 and later, SVt_RV == SVt_IV, so sv could be a valid integer value. */ + if (SvIOK(sv)) { + return SWIG_ERROR; + } else { + /* NULL pointer (reference to undef). */ + *(ptr) = (void *) 0; + return SWIG_OK; + } } else { return SWIG_ERROR; }