This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Skip the scope name checks if PL_scopestack_name is NULL.
authorNicholas Clark <nick@ccl4.org>
Wed, 18 Nov 2009 15:47:35 +0000 (15:47 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 18 Nov 2009 15:47:35 +0000 (15:47 +0000)
It's possible that someone has built a module with -DDEBUGGING, but they're
using it against a perl built non-DEBUGGING, in which case PL_scopestack_name
will be NULL. Better to skip the checks than to SEGV.

scope.h

diff --git a/scope.h b/scope.h
index 2f50398..64e7e27 100644 (file)
--- a/scope.h
+++ b/scope.h
@@ -134,15 +134,18 @@ scope has the given name. Name must be a literal string.
 #define ENTER_with_name(name)                                          \
     STMT_START {                                                       \
        push_scope();                                                   \
 #define ENTER_with_name(name)                                          \
     STMT_START {                                                       \
        push_scope();                                                   \
-       PL_scopestack_name[PL_scopestack_ix-1] = name;                  \
+       if (PL_scopestack_name)                                         \
+           PL_scopestack_name[PL_scopestack_ix-1] = name;              \
        DEBUG_SCOPE("ENTER \"" name "\"")                               \
     } STMT_END
 #define LEAVE_with_name(name)                                          \
     STMT_START {                                                       \
        DEBUG_SCOPE("LEAVE \"" name "\"")                               \
        DEBUG_SCOPE("ENTER \"" name "\"")                               \
     } STMT_END
 #define LEAVE_with_name(name)                                          \
     STMT_START {                                                       \
        DEBUG_SCOPE("LEAVE \"" name "\"")                               \
-       assert(((char*)PL_scopestack_name[PL_scopestack_ix-1]           \
-                   == (char*)name)                                     \
-               || strEQ(PL_scopestack_name[PL_scopestack_ix-1], name));        \
+       if (PL_scopestack_name) {                                       \
+           assert(((char*)PL_scopestack_name[PL_scopestack_ix-1]       \
+                       == (char*)name)                                 \
+                   || strEQ(PL_scopestack_name[PL_scopestack_ix-1], name));        \
+       }                                                               \
        pop_scope();                                                    \
     } STMT_END
 #else
        pop_scope();                                                    \
     } STMT_END
 #else