better POD for SvPVX, pre-5.9.3 Perls
authorDaniel Dragan <bulk88@hotmail.com>
Wed, 6 Mar 2013 03:51:01 +0000 (22:51 -0500)
committerNicholas Clark <nick@ccl4.org>
Wed, 6 Mar 2013 12:01:43 +0000 (13:01 +0100)
PV/char * was moved to SV head in commit 7b2c381cf3 . Prior to this, PV
was in SV body, and sv_any can be NULL, so accessing SvPVX without
checking type on old Perls was a SEGV. Make a note of this so others
don't find out the hard way.

sv.h

diff --git a/sv.h b/sv.h
index 94ba1e6..fd3da2d 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -730,7 +730,8 @@ Only use when you are sure SvNOK is true.  See also C<SvNV()>.
 
 =for apidoc Am|char*|SvPVX|SV* sv
 Returns a pointer to the physical string in the SV.  The SV must contain a
-string.
+string. Prior to 5.9.3 it is not safe to execute this macro unless the SV's
+type >= SVt_PV.
 
 This is also used to store the name of an autoloaded subroutine in an XS
 AUTOLOAD routine.  See L<perlguts/Autoloading with XSUBs>.