Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
[PATCH] fix sv_usepvn_flags's docs #13835
Created by @bulk88
See attached patch. I'd like this in for 5.20 since #116925
From 6a80a09ff167581a49ad3d65db8030fe03bcd823 Mon Sep 17 00:00:00 2001 From: Daniel Dragan <firstname.lastname@example.org> Date: Wed, 14 May 2014 04:08:13 -0400 Subject: [PATCH 1/2] fix sv_usepvn_flags's docs Newx != malloc, mixing Newx and malloc leads to heap corruption on some builds like Win32, use the official Perl API for allocating memory. --- sv.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sv.c b/sv.c index 1005313..b43fadf 100644 --- a/sv.c +++ b/sv.c @@ -4846,10 +4846,12 @@ Perl_sv_sethek(pTHX_ SV *const sv, const HEK *const hek) Tells an SV to use C<ptr> to find its string value. Normally the string is stored inside the SV but sv_usepvn allows the SV to use an outside string. The C<ptr> should point to memory that was allocated -by C<malloc>. It must be the start of a mallocked block -of memory, and not a pointer to the middle of it. The -string length, C<len>, must be supplied. By default -this function will realloc (i.e. move) the memory pointed to by C<ptr>, +by L<Newx|perlclib/Memory Management and String Handling>. It must be +the start of a Newx-ed block of memory, and not a pointer to the +middle of it (beware of L<OOK|perlguts/Offsets> and copy-on-write), +and not be from a non-Newx memory allocator like C<malloc>. The +string length, C<len>, must be supplied. By default this function +will C<Renew> (i.e. realloc, move) the memory pointed to by C<ptr>, so that pointer should not be freed or used by the programmer after giving it to sv_usepvn, and neither should any pointers from "behind" that pointer (e.g. ptr + 1) be used. -- 1.7.9.msysgit.0
On Wed May 14 01:30:51 2014, bulk88 wrote:
Added as a 5.21.1 blocker.