diff options
author | jpl <jpl.jpl@gmail.com> | 2017-08-28 09:54:15 -0400 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2017-09-21 11:00:41 +1000 |
commit | 0e1d050c8bc9db9872018aa565cc957f8169e50c (patch) | |
tree | 039b05011266c3171f420330e893867ad73d2666 /pp_sort.c | |
parent | 8200f8061dc056efb643917d5e90c8ee0aad8fd2 (diff) | |
download | perl-0e1d050c8bc9db9872018aa565cc957f8169e50c.tar.gz |
Change save/restore behavior for comparisons
S_mergesortsv was saving the current comparison routine only when the
SORTf_DESC flag was set, but "restoring" it when ANY flag was set.
When some flag other than SORTf_DESC was set, this could lead to
the pointer to the comparison routine being set to NULL,
triggering a segfault when the routine was subsequently invoked.
Diffstat (limited to 'pp_sort.c')
-rw-r--r-- | pp_sort.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -558,7 +558,7 @@ S_mergesortsv(pTHX_ gptr *base, size_t nmemb, SVCOMPARE_t cmp, U32 flags) } done: if (aux != small) Safefree(aux); /* free iff allocated */ - if (flags) { + if (savecmp != NULL) { PL_sort_RealCmp = savecmp; /* Restore current comparison routine, if any */ } return; |