From: Adam Dickmeiss Date: Tue, 12 Aug 2008 08:56:10 +0000 (+0200) Subject: Fixed memory leak that occurred if sorting failed. X-Git-Tag: v2.0.34~43 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=d5170943ca365ace791c3254db15cc852df56d6b;p=idzebra-moved-to-github.git Fixed memory leak that occurred if sorting failed. --- 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",