This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add Perl_dup_warnings() and fix leak
authorDavid Mitchell <davem@iabyn.com>
Mon, 25 Feb 2019 13:05:04 +0000 (13:05 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 27 Feb 2019 10:37:49 +0000 (10:37 +0000)
commitc1e47bad34ce1d9c84ed57c9b8978bcbd5a02e98
tree4f4ce1ae4484c07f5b5472724dd73d2115cdb583
parent6096c8b5a857766814f7e67361965635283f2354
add Perl_dup_warnings() and fix leak

The macro DUP_WARNINGS() was doing (approximately)

    new = CopyD(old, malloc(size), size);

which, depending on how the CopyD macro expanded (e.g. on debugging
builds), could result in its arguments being used multiple times, and
thus malloc() being called multiple times, with the result of the
earlier call(s) then leaking.

Fix this by implementing DUP_WARNINGS using a new function,
Perl_dup_warnings() that stores its intermediate values in local vars.

This function isn't performance critical, as its usually only called
once per cop creation at compile time.
embed.fnc
op.c
proto.h
regen/warnings.pl
warnings.h