From fb072d007726c7ba114978a00f8f4f687ad7a55a Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Thu, 29 Oct 2020 15:59:16 +1100 Subject: remove assertion that collation magic has data This broke on some smokers where the locale collation data was broken in some way (and rejected by the collation setup code.) It also broke if collation magic was generated for an SV and then the SV was modified, freeing the collation data before the SV was destroyed. --- mg.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'mg.c') diff --git a/mg.c b/mg.c index d14b2eb88c..32d7732bc6 100644 --- a/mg.c +++ b/mg.c @@ -2669,9 +2669,12 @@ Perl_magic_freecollxfrm(pTHX_ SV *sv, MAGIC *mg) /* Collate magic uses mg_len as a string length rather than a buffer * length, so we need to free even with mg_len == 0: hence we can't * rely on standard magic free handling */ - assert(mg->mg_type == PERL_MAGIC_collxfrm && mg->mg_len >= 0); - Safefree(mg->mg_ptr); - mg->mg_ptr = NULL; + if (mg->mg_len >= 0) { + assert(mg->mg_type == PERL_MAGIC_collxfrm); + Safefree(mg->mg_ptr); + mg->mg_ptr = NULL; + } + return 0; } #endif /* USE_LOCALE_COLLATE */ -- cgit v1.2.1