summaryrefslogtreecommitdiff
path: root/dist/Carp
diff options
context:
space:
mode:
authorJ. Nick Koston <nick@cpanel.net>2017-10-12 01:57:36 -0500
committerNicolas R <atoomic@cpan.org>2017-11-21 14:36:32 -0700
commit915a6810d3e3198d759f025f85d1fd6f3171dd27 (patch)
tree2499fa49f70952103a26b0120f0d457873bd2293 /dist/Carp
parenta23a60c662bf62e13443a668f998815460404532 (diff)
downloadperl-915a6810d3e3198d759f025f85d1fd6f3171dd27.tar.gz
Carp: optimize format_arg when arguments contain many references
RT #132274 This is a very minimal patch after RT discussion. When using the CPAN version of UNIVERSAL::isa we cannot use UNIVERSAL::isa on Carp without taking the risk of going into one infinite loop. As UNIVERSAL::isa on CPAN is the only one to advertise a VERSION, we can use this value to disable the UNIVERSAL check. Note version bump is not required as it already occurred since v5.27.5 release. Signed-off-by: Nicolas R <atoomic@cpan.org>
Diffstat (limited to 'dist/Carp')
-rw-r--r--dist/Carp/Changes4
-rw-r--r--dist/Carp/lib/Carp.pm7
2 files changed, 10 insertions, 1 deletions
diff --git a/dist/Carp/Changes b/dist/Carp/Changes
index 0498eeb885..db187e9443 100644
--- a/dist/Carp/Changes
+++ b/dist/Carp/Changes
@@ -1,3 +1,7 @@
+version 1.44
+
+ * Optimize format_arg when arguments contain many references
+
version 1.43
* fix problems introduced by the partial EBCDIC support from version
diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm
index 623558aada..3c5764cefc 100644
--- a/dist/Carp/lib/Carp.pm
+++ b/dist/Carp/lib/Carp.pm
@@ -283,8 +283,13 @@ sub format_arg {
my $arg = shift;
if ( ref($arg) ) {
+
+ # lazy check if the CPAN module UNIVERSAL::isa is used or not
+ # if we use a rogue version of UNIVERSAL this would lead to infinite loop
+ my $isa = $UNIVERSAL::isa::VERSION ? sub { 1 } : \&UNIVERSAL::isa;
+
# legitimate, let's not leak it.
- if (!$in_recurse &&
+ if (!$in_recurse && $isa->( $arg, 'UNIVERSAL' ) &&
do {
local $@;
local $in_recurse = 1;