diff options
author | David Mitchell <davem@iabyn.com> | 2021-02-22 10:00:27 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2021-02-22 10:00:27 +0000 |
commit | 5d273abb14ecf2af8a75115442c938b8a5979ebe (patch) | |
tree | 8b77d07fbea7e7985d7a03942d96a929454f8659 /mg.c | |
parent | b3a019b423725caa4eb6a8615a6c1367b85326b0 (diff) | |
download | perl-5d273abb14ecf2af8a75115442c938b8a5979ebe.tar.gz |
fixup Perl_magic_freemglob()
In v5.33.3-24-g02a48966c3 I added the Perl_magic_freemglob() function,
which allowed special-case handling of the pos() magic type to be
removed from S_mg_free_struct().
However, I got it wrong, by more or less copying the same code from
another such function I had just created. So I made
Perl_magic_freemglob() free mg_ptr(), but in the case of pos magic, this
doesn't point to a buffer which needs freeing. In fact its currently
always NULL so attempting to free it is harmless - but this commit
removes the free() for logical soundness and future robustness.
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -2600,11 +2600,10 @@ Perl_magic_freemglob(pTHX_ SV *sv, MAGIC *mg) PERL_ARGS_ASSERT_MAGIC_FREEMGLOB; PERL_UNUSED_ARG(sv); - /* glob 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 */ + /* pos() magic uses mg_len as a string position rather than a buffer + * length, and mg_ptr is currently unused, so skip freeing. + */ assert(mg->mg_type == PERL_MAGIC_regex_global && mg->mg_len >= -1); - Safefree(mg->mg_ptr); mg->mg_ptr = NULL; return 0; } |