From e983bd7a40f013079d8e168def01cf823055a62a Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Wed, 13 Nov 2013 17:30:10 +0000 Subject: [PATCH] Opcode: fix 'null argument' warning HvNAME_get() can return NULL, and strNE() wants non-null args. [ As a side note: on debugging builds this line if (strNE(HvNAME_get(hv),"main")) { macro-expands into an 18,000 character line (!) due to the fact that HvNAME_get() is quite a big expansion under debugging, and strNE expands to strlen, which under gcc expands to a huge macro (which is mainly lots of different compile-time alternatives depending on which of its args are constants), that references its args several times. ] --- ext/Opcode/Opcode.pm | 2 +- ext/Opcode/Opcode.xs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/Opcode/Opcode.pm b/ext/Opcode/Opcode.pm index 48b6ae0..a48b01d 100644 --- a/ext/Opcode/Opcode.pm +++ b/ext/Opcode/Opcode.pm @@ -6,7 +6,7 @@ use strict; our($VERSION, @ISA, @EXPORT_OK); -$VERSION = "1.26"; +$VERSION = "1.27"; use Carp; use Exporter (); diff --git a/ext/Opcode/Opcode.xs b/ext/Opcode/Opcode.xs index 4e6af8d..386dddf 100644 --- a/ext/Opcode/Opcode.xs +++ b/ext/Opcode/Opcode.xs @@ -257,11 +257,13 @@ _safe_pkg_prep(Package) SV *Package PPCODE: HV *hv; + char *hvname; ENTER; hv = gv_stashsv(Package, GV_ADDWARN); /* should exist already */ - if (strNE(HvNAME_get(hv),"main")) { + hvname = HvNAME_get(hv); + if (!hvname || strNE(hvname, "main")) { /* make it think it's in main:: */ hv_name_set(hv, "main", 4, 0); (void) hv_store(hv,"_",1,(SV *)PL_defgv,0); /* connect _ to global */ -- 2.7.4