Minor leak fixes - in case if zebra_register_open fail.
authorAdam Dickmeiss <adam@indexdata.dk>
Sat, 25 Mar 2006 15:33:29 +0000 (15:33 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Sat, 25 Mar 2006 15:33:29 +0000 (15:33 +0000)
index/zebraapi.c

index d89c263..b036ff1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebraapi.c,v 1.204 2006-03-23 09:15:25 adam Exp $
+/* $Id: zebraapi.c,v 1.205 2006-03-25 15:33:29 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -299,6 +299,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name,
     reg->dh = data1_createx (DATA1_FLAG_XML);
     if (!reg->dh)
     {
+       xfree(reg->name);
        xfree(reg);
         return 0;
     }
@@ -306,6 +307,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name,
     if (!reg->bfs)
     {
         data1_destroy(reg->dh);
+       xfree(reg->name);
        xfree(reg);
         return 0;
     }
@@ -315,6 +317,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name,
        {
            bfs_destroy(reg->bfs);
            data1_destroy(reg->dh);
+           xfree(reg->name);
            xfree(reg);
            return 0;
        }
@@ -328,10 +331,12 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name,
     data1_set_tabroot (reg->dh, reg_path);
     reg->recTypes = recTypes_init (zs->record_classes, reg->dh);
 
-    if ((reg->zebra_maps = zebra_maps_open (res, reg_path)) == 0) {
-       /* ### Do we need to destroy reg->recTypes? */
+    if ((reg->zebra_maps = zebra_maps_open (res, reg_path)) == 0)
+    {
+       recTypes_destroy(reg->recTypes);
        bfs_destroy(reg->bfs);
        data1_destroy(reg->dh);
+       xfree(reg->name);
        xfree(reg);
        return 0;
     }
@@ -1670,7 +1675,7 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw)
                     yaz_log (YLOG_WARN, "previous transaction didn't reach commit");
                     bf_commitClean (bfs, rval);
                     bfs_destroy (bfs);
-            }
+               }
                 else
                 {
                     yaz_log (YLOG_WARN, "your previous transaction didn't finish");