Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

geoff (2013)

  reversethis-{gro ... om} {ta} {ffoeg}

see [] for personal information, links to presentations, GPG key, and so on.

Journal of geoff (2013)

Wednesday March 10, 2004
02:59 AM

are you SvOK?

[ #17842 ]
it turns out a bug (that I introduced) in mod_perl 1.0 core could be boiled down to this simple XS:

RETVAL = Nullsv;

if (! SvOK(RETVAL)) {

as it turns out, Nullsv really expands to

#define Nullsv Null(SV*)

then to

#define Null(type) ((type)NULL)

now, maybe it's obvious to the perl core gurus, but I never would have expected SvOK not to protect against situations like these, especially while SvTRUE is DWIMmy. but that's just me.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • As a matter of fact, I always used SvOK to check that an SV is non-NULL, oups. Whereas I only used SvTRUE after I tested for nun-NULLness (with the help of SvOK of course:-).

    A patch to SvOK adding a NULL-check would probably be in order.
    • I'd rather have a doc patch. Lots of macros don't check the nullness of their argument. As a matter of fact null SVs are quite rare compared to &PL_sv_undef or &PL_sv_no.
    • --- sv.h        2004-03-07 09:06:01.000000000 -0800
      +++ sv.h~       2004-03-10 10:03:23.000000000 -0800
      @@ -428,7 +428,8 @@
      Unsets the NV/IV status of an SV.

      =for apidoc Am|bool|SvOK|SV* sv
      -Returns a boolean indicating whether the value is an SV.
      +Returns a boolean indicating whether the value is an SV.  Does not protect
      +against NULL SVs, such as those created by C<Nullsv>.

      =for apidoc Am|bool|SvIOKp|SV* sv
      Returns a boolean indicating whether the SV contai

  • I prefer to be a SvOOK