Change 31312 by [EMAIL PROTECTED] on 2007/05/30 15:21:10

        Subject: Re: HvMROMETA
        From: "Brandon Black" <[EMAIL PROTECTED]>
        Date: Tue, 29 May 2007 19:08:13 -0500
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/hv.h#108 edit
... //depot/perl/mro.c#22 edit

Differences ...

==== //depot/perl/hv.h#108 (text) ====
Index: perl/hv.h
--- perl/hv.h#107~31239~        2007-05-18 18:00:15.000000000 -0700
+++ perl/hv.h   2007-05-30 08:21:10.000000000 -0700
@@ -261,9 +261,13 @@
 #define HvRITER_get(hv)        (SvOOK(hv) ? HvAUX(hv)->xhv_riter : -1)
 #define HvEITER_get(hv)        (SvOOK(hv) ? HvAUX(hv)->xhv_eiter : 0)
 #define HvNAME(hv)     HvNAME_get(hv)
-#define HvMROMETA(hv)  (SvOOK(hv) \
-                       ? (HvAUX(hv)->xhv_mro_meta ? HvAUX(hv)->xhv_mro_meta : 
mro_meta_init(hv)) \
-                       : NULL)
+
+/* Checking that hv is a valid package stash is the
+   caller's responsibility */
+#define HvMROMETA(hv) (HvAUX(hv)->xhv_mro_meta \
+                       ? HvAUX(hv)->xhv_mro_meta \
+                       : mro_meta_init(hv))
+
 /* FIXME - all of these should use a UTF8 aware API, which should also involve
    getting the length. */
 /* This macro may go away without notice.  */

==== //depot/perl/mro.c#22 (text) ====
Index: perl/mro.c
--- perl/mro.c#21~31239~        2007-05-18 18:00:15.000000000 -0700
+++ perl/mro.c  2007-05-30 08:21:10.000000000 -0700
@@ -411,8 +411,10 @@
 Perl_mro_get_linear_isa(pTHX_ HV *stash)
 {
     struct mro_meta* meta;
+
     assert(stash);
-    assert(HvAUX(stash));
+    if(!SvOOK(stash))
+        Perl_croak(aTHX_ "Can't linearize anonymous symbol table");
 
     meta = HvMROMETA(stash);
     if(meta->mro_which == MRO_DFS) {
@@ -444,12 +446,16 @@
     SV** svp;
     I32 items;
     bool is_universal;
+    struct mro_meta * meta;
 
     const char * const stashname = HvNAME_get(stash);
     const STRLEN stashname_len = HvNAMELEN_get(stash);
 
+    if(!stashname)
+        Perl_croak(aTHX_ "Can't call mro_isa_changed_in() on anonymous symbol 
table");
+
     /* wipe out the cached linearizations for this stash */
-    struct mro_meta * const meta = HvMROMETA(stash);
+    meta = HvMROMETA(stash);
     SvREFCNT_dec((SV*)meta->mro_linear_dfs);
     SvREFCNT_dec((SV*)meta->mro_linear_c3);
     meta->mro_linear_dfs = NULL;
@@ -577,6 +583,9 @@
     SV ** const svp = hv_fetch(PL_isarev, stashname, stashname_len, 0);
     HV * const isarev = svp ? (HV*)*svp : NULL;
 
+    if(!stashname)
+        Perl_croak(aTHX_ "Can't call mro_method_changed_in() on anonymous 
symbol table");
+
     /* Inc the package generation, since a local method changed */
     HvMROMETA(stash)->pkg_gen++;
 
End of Patch.

Reply via email to