summaryrefslogtreecommitdiff
path: root/pp_sort.c
diff options
context:
space:
mode:
authorjpl <jpl.jpl@gmail.com>2017-08-28 09:54:15 -0400
committerTony Cook <tony@develop-help.com>2017-09-21 11:00:41 +1000
commit0e1d050c8bc9db9872018aa565cc957f8169e50c (patch)
tree039b05011266c3171f420330e893867ad73d2666 /pp_sort.c
parent8200f8061dc056efb643917d5e90c8ee0aad8fd2 (diff)
downloadperl-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.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pp_sort.c b/pp_sort.c
index 604950910a..9d31bdafe0 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -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;