In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/4bf31405101ba885e9cddbf63b64e9b298992509?hp=8975657c9f0008493ae520806e9c3ed354ddfd9c>
- Log ----------------------------------------------------------------- commit 4bf31405101ba885e9cddbf63b64e9b298992509 Author: Colin Newell <[email protected]> Date: Tue Jan 3 19:56:13 2017 +0000 Documentation patch to recommend newSVpvn over newSVpv. (Committer made a couple of grammatical corrections) ----------------------------------------------------------------------- Summary of changes: AUTHORS | 1 + sv.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index e5eff7914c..6c2dd2131f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -259,6 +259,7 @@ Clinton A. Pierce <[email protected]> Colin Kuskie <[email protected]> Colin McMillen <[email protected]> Colin Meyer <[email protected]> +Colin Newell <[email protected]> Colin Watson <[email protected]> Conrad Augustin Conrad E. Kimball <[email protected]> diff --git a/sv.c b/sv.c index 42e34410ed..bbdca0bf08 100644 --- a/sv.c +++ b/sv.c @@ -9323,7 +9323,14 @@ SV is set to 1. If C<len> is zero, Perl will compute the length using C<strlen()>, (which means if you use this option, that C<s> can't have embedded C<NUL> characters and has to have a terminating C<NUL> byte). -For efficiency, consider using C<newSVpvn> instead. +This function can cause reliability issues if you are likely to pass in +empty strings that are not null terminated, because it will run +strlen on the string and potentially run past valid memory. + +Using L</newSVpvn> is a safer alternative for non C<NUL> terminated strings. +For string literals use L</newSVpvs> instead. This function will work fine for +C<NUL> terminated strings, but if you want to avoid the if statement on whether +to call C<strlen> use C<newSVpvn> instead (calling C<strlen> yourself). =cut */ -- Perl5 Master Repository
