This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix change #28552: VC++ doesn't like code before declarations
[perl5.git] / ext / Hash / Util / FieldHash / FieldHash.xs
index 91107dd..44ff3ce 100644 (file)
@@ -20,14 +20,24 @@ START_MY_CXT
 /* Inquire the object registry (a lexical hash) from perl */
 HV* HUF_get_ob_reg(void) {
     dSP;
-    I32 items = call_pv(HUF_OB_REG, G_SCALAR|G_NOARGS);
+    HV* ob_reg = NULL;
+    I32 items;
+    ENTER;
+    SAVETMPS;
+
+    PUSHMARK(SP);
+    items = call_pv(HUF_OB_REG, G_SCALAR|G_NOARGS);
     SPAGAIN;
-    if (items == 1) {
-        SV* ref = POPs;
-        PUTBACK;
-        if (ref && SvROK(ref) && SvTYPE(SvRV(ref)) == SVt_PVHV)
-            return (HV*)SvRV(ref);
+
+    if (items == 1 && TOPs && SvROK(TOPs) && SvTYPE(SvRV(TOPs)) == SVt_PVHV) {
+        ob_reg = (HV*)SvRV(POPs);
     }
+    PUTBACK;
+    FREETMPS;
+    LEAVE;
+
+    if (ob_reg)
+        return ob_reg;
     Perl_die(aTHX_ "Can't get object registry hash");
 }