-#if SU_HAS_PERL(5, 8, 0)
- if (MY_CXT.uplevel_storage.count >= SU_UPLEVEL_STORAGE_SIZE) {
- /* When an exception is thrown from the uplevel'd subroutine,
- * su_uplevel_restore() may be called by the LEAVE in die_unwind() (renamed
- * die_where() in more recent perls), which has the sad habit of keeping a
- * pointer to the current context frame across this call. This means that
- * we can't free the temporary context stack we used for the uplevel call
- * right now, or that pointer upwards would point to garbage. We work around
- * this by attaching the state data to a scalar that will be freed "soon".
- * This issue has been fixed in perl with commit 8f89e5a9. */
+ /* When an exception is thrown from the uplevel'd subroutine,
+ * su_uplevel_restore() may be called by the LEAVE in die_unwind() (renamed
+ * die_where() in more recent perls), which has the sad habit of keeping a
+ * pointer to the current context frame across this call. This means that we
+ * can't free the temporary context stack we used for the uplevel call right
+ * now, or that pointer upwards would point to garbage. */
+#if SU_HAS_PERL(5, 13, 7)
+ /* This issue has been fixed in perl with commit 8f89e5a9, which was made
+ * public in perl 5.13.7. */
+ su_uplevel_storage_delete(sud);
+#elif SU_HAS_EXT_MAGIC
+ /* If 'ext' magic is available, we work around this by attaching the state
+ * data to a scalar that will be freed "soon". */
+ {