dMY_CXT;
ptable_hints_free(MY_CXT.tbl);
+ MY_CXT.tbl = NULL;
ptable_seen_free(MY_CXT.seen);
+ MY_CXT.seen = NULL;
+ SvREFCNT_dec(MY_CXT.default_meth);
+ MY_CXT.default_meth = NULL;
}
STATIC int lt_endav_free(pTHX_ SV *sv, MAGIC *mg) {
STATIC SV *lt_tag(pTHX_ SV *value) {
#define lt_tag(V) lt_tag(aTHX_ (V))
lt_hint_t *h;
- SV *code = NULL;
+ SV *code = NULL;
+#if LT_THREADSAFE
+ dMY_CXT;
+
+ if (!MY_CXT.tbl)
+ return newSViv(0);
+#endif /* LT_THREADSAFE */
if (SvROK(value)) {
value = SvRV(value);
#endif /* !LT_HINT_STRUCT */
#if LT_THREADSAFE
- {
- dMY_CXT;
- /* We only need for the key to be an unique tag for looking up the value later
- * Allocated memory provides convenient unique identifiers, so that's why we
- * use the hint as the key itself. */
- ptable_hints_store(MY_CXT.tbl, h, h);
- }
+ /* We only need for the key to be an unique tag for looking up the value later
+ * Allocated memory provides convenient unique identifiers, so that's why we
+ * use the hint as the key itself. */
+ ptable_hints_store(MY_CXT.tbl, h, h);
#endif /* LT_THREADSAFE */
return newSViv(PTR2IV(h));
lt_hint_t *h;
#if LT_THREADSAFE
dMY_CXT;
-#endif
+
+ if (!MY_CXT.tbl)
+ return NULL;
+#endif /* LT_THREADSAFE */
if (!(hint && SvIOK(hint)))
return NULL;
if (stash && (code = lt_hint())) {
dMY_CXT;
SV *orig_pkg = newSVpvn(HvNAME_get(stash), HvNAMELEN_get(stash));
- SV *orig_meth = MY_CXT.default_meth;
+ SV *orig_meth = MY_CXT.default_meth; /* Guarded by lt_hint() */
SV *type_pkg = NULL;
SV *type_meth = NULL;
int items;
lt_old_peep(aTHX_ o);
- ptable_seen_clear(seen);
- lt_peep_rec(o);
- ptable_seen_clear(seen);
+ if (seen) {
+ ptable_seen_clear(seen);
+ lt_peep_rec(o);
+ ptable_seen_clear(seen);
+ }
}
/* --- Interpreter setup/teardown ------------------------------------------ */
dMY_CXT;
#if LT_THREADSAFE
ptable_hints_free(MY_CXT.tbl);
+ MY_CXT.tbl = NULL;
#endif
ptable_seen_free(MY_CXT.seen);
+ MY_CXT.seen = NULL;
SvREFCNT_dec(MY_CXT.default_meth);
+ MY_CXT.default_meth = NULL;
}
lt_ck_restore(OP_PADANY, <_old_ck_padany);