From d5170943ca365ace791c3254db15cc852df56d6b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 12 Aug 2008 10:56:10 +0200 Subject: [PATCH] Fixed memory leak that occurred if sorting failed. --- index/zsets.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/index/zsets.c b/index/zsets.c index 9054cfe..ce615ff 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -907,8 +907,10 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem, Z_SortKey *sk; ZEBRA_RES res; - sort_criteria[i].ord = (int *)xmalloc(sizeof(int)*numbases); - sort_criteria[i].numerical = (int *)xmalloc(sizeof(int)*numbases); + sort_criteria[i].ord = (int *) + nmem_malloc(nmem, sizeof(int)*numbases); + sort_criteria[i].numerical = (int *) + nmem_malloc(nmem, sizeof(int)*numbases); // initialize ord and numerical for each database for (ib = 0; ib < numbases; ib++) @@ -1038,9 +1040,6 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem, { xfree(cmp_buf[i]); xfree(tmp_cmp_buf[i]); - // and the criteria - xfree(sort_criteria[i].ord); - xfree(sort_criteria[i].numerical); } yaz_log(log_level_sort, ZINT_FORMAT " keys, " ZINT_FORMAT " sysnos, sort", -- 1.7.10.4