From d1fb65aa541a7a50654b8b224f0b5303ebd9c516 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Wed, 14 Jun 2006 09:15:28 +0000 Subject: [PATCH] Fix leak of temporary connections created by ZOOM_query_c[cq]l2rpn() Thanks to Adam for spotting this. --- src/zoom-c.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/zoom-c.c b/src/zoom-c.c index 05371be..169037f 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.76 2006-06-13 16:27:23 mike Exp $ + * $Id: zoom-c.c,v 1.77 2006-06-14 09:15:28 mike Exp $ */ /** * \file zoom-c.c @@ -565,12 +565,16 @@ ZOOM_query_cql2rpn(ZOOM_query s, const char *str, ZOOM_connection conn) { char *rpn; int ret; + ZOOM_connection freeme = 0; yaz_log(log_details, "%p ZOOM_query_cql2rpn str=%s conn=%p", s, str, conn); if (conn == 0) - conn = ZOOM_connection_create(0); + conn = freeme = ZOOM_connection_create(0); - if ((rpn = cql2pqf(conn, str)) == 0) + rpn = cql2pqf(conn, str); + if (freeme != 0) + ZOOM_connection_destroy(freeme); + if (rpn == 0) return -1; ret = ZOOM_query_prefix(s, rpn); @@ -588,12 +592,16 @@ ZOOM_query_ccl2rpn(ZOOM_query s, const char *str, ZOOM_connection conn) { char *rpn; int ret; + ZOOM_connection freeme = 0; yaz_log(log_details, "%p ZOOM_query_ccl2rpn str=%s conn=%p", s, str, conn); if (conn == 0) - conn = ZOOM_connection_create(0); + conn = freeme = ZOOM_connection_create(0); - if ((rpn = ccl2pqf(conn, str)) == 0) + rpn = ccl2pqf(conn, str); + if (freeme != 0) + ZOOM_connection_destroy(freeme); + if (rpn == 0) return -1; ret = ZOOM_query_prefix(s, rpn); @@ -1180,7 +1188,7 @@ static zoom_ret ZOOM_connection_send_init (ZOOM_connection c) ZOOM_options_get(c->options, "implementationName"), odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.76 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.77 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = odr_prepend(c->odr_out, -- 1.7.10.4