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
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.