From 510c122aceb2b7a3ec12a6be3de610f0ff470ae4 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sun, 26 Mar 2006 14:05:19 +0000 Subject: [PATCH] Fix zebra_maps_open not to leak if default.idx cannot be found --- util/res.c | 4 ++-- util/zebramap.c | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/util/res.c b/util/res.c index 4e26a7a..4fbc33c 100644 --- a/util/res.c +++ b/util/res.c @@ -1,4 +1,4 @@ -/* $Id: res.c,v 1.47 2005-10-27 08:49:29 adam Exp $ +/* $Id: res.c,v 1.48 2006-03-26 14:05:19 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -379,7 +379,7 @@ ZEBRA_RES res_write_file(Res r, const char *fname) if (!fr) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "Cannot create `%s'", fname); - exit(1); + return ZEBRA_FAIL; } for (re = r->first; re; re=re->next) diff --git a/util/zebramap.c b/util/zebramap.c index 9c03d0b..5f472b9 100644 --- a/util/zebramap.c +++ b/util/zebramap.c @@ -1,4 +1,4 @@ -/* $Id: zebramap.c,v 1.44 2006-03-13 17:40:28 mike Exp $ +/* $Id: zebramap.c,v 1.45 2006-03-26 14:05:19 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -181,14 +181,16 @@ ZebraMaps zebra_maps_open (Res res, const char *base) zms->lookup_array = (struct zebra_map**) nmem_malloc (zms->nmem, sizeof(*zms->lookup_array)*256); + zms->wrbuf_1 = wrbuf_alloc(); + for (i = 0; i<256; i++) zms->lookup_array[i] = 0; if (!res || !res_trav (res, "index", zms, zms_map_handle)) if (zebra_map_read (zms, "default.idx", 1) < 0) + { + zebra_maps_close(zms); return 0; - - zms->wrbuf_1 = wrbuf_alloc(); - + } return zms; } -- 1.7.10.4