This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactor some calls to eval_ok() into is(eval $foo ...) and is($@, '') pairs.
[perl5.git] / mro.c
diff --git a/mro.c b/mro.c
index fd805d6..115da8b 100644 (file)
--- a/mro.c
+++ b/mro.c
@@ -752,7 +752,7 @@ Perl_mro_package_moved(pTHX_ HV * const stash, HV * const oldstash,
     }
     if (name_count == 1) {
        if (HEK_LEN(*namep) == 4 && strnEQ(HEK_KEY(*namep), "main", 4)) {
-           namesv = sv_2mortal(newSVpvs(""));
+           namesv = newSVpvs_flags("", SVs_TEMP);
        }
        else {
            namesv = sv_2mortal(newSVhek(*namep));
@@ -830,7 +830,7 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
     register XPVHV* xhv;
     register HE *entry;
     I32 riter = -1;
-    I32 items;
+    I32 items = 0;
     const bool stash_had_name = stash && HvENAME(stash);
     bool fetched_isarev = FALSE;
     HV *seen = NULL;
@@ -939,7 +939,7 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
        * mro_isa_changed_in called on it. That happens if it was
        * detached from the symbol table (so it had no HvENAME) before
        * being assigned to the spot named by the ‘name’ variable, because
-       * its cached isa linerisation is now stale (the effective name
+       * its cached isa linearisation is now stale (the effective name
        * having changed), and subclasses will then use that cache when
        * mro_package_moved calls mro_isa_changed_in. (See
        * [perl #77358].)
@@ -984,16 +984,20 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
     if(!fetched_isarev) {
        /* If oldstash is not null, then we can use its HvENAME to look up
           the isarev hash, since all its subclasses will be listed there.
+          It will always have an HvENAME. It the HvENAME was removed
+          above, then fetch_isarev will be true, and this code will not be
+          reached.
 
           If oldstash is null, then this is an empty spot with no stash in
           it, so subclasses could be listed in isarev hashes belonging to
-          any of the names, so we have to check all of them. */
-       if(oldstash) {
+          any of the names, so we have to check all of them.
+        */
+       assert(!oldstash || HvENAME(oldstash));
+       if (oldstash) {
+           /* Extra variable to avoid a compiler warning */
+           char * const hvename = HvENAME(oldstash);
            fetched_isarev = TRUE;
-           svp
-            = hv_fetch(
-                PL_isarev, HvENAME(oldstash), HvENAMELEN_get(oldstash), 0
-              );
+           svp = hv_fetch(PL_isarev, hvename, HvENAMELEN_get(oldstash), 0);
            if (svp) isarev = MUTABLE_HV(*svp);
        }
        else if(SvTYPE(namesv) == SVt_PVAV) {