freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Iain Calder <iain.calder AT blueyonder.co.uk>
- To: freetds AT lists.ibiblio.org
- Subject: [freetds] ct_param memory leak patch
- Date: Thu, 15 Jan 2004 18:44:47 +0000
First I would like to thank everyone who contributed to the 0.62 release. I
am using FreeTDS-ctlib to call stored procedures on SQL Server 2000 from
Linux with great success.
I have noticed a couple of memory leaks when using ct_param to add stored procedure parameters. ct_param() seems to create temporary param structures which are not freed, and ct_cmd_drop() does not free cmd->rpc structures.
The following patch to ct.c appears to correct the leaks:
--- freetds-0.62/src/ctlib/ct.c 2003-12-26 18:11:08.000000000 +0000
+++ freetds-0.62.new/src/ctlib/ct.c 2004-01-15 14:05:30.000000000 +0000
@@ -1446,6 +1446,13 @@
free(cmd->query);
if (cmd->input_params)
param_clear(cmd->input_params);
+ if (cmd->rpc)
+ {
+ if (cmd->rpc->param_list)
+ param_clear(cmd->rpc->param_list);
+ free(cmd->rpc->name);
+ free(cmd->rpc);
+ }
free(cmd);
}
return CS_SUCCEED;
@@ -2657,16 +2664,14 @@
rpc = cmd->rpc;
pparam = &rpc->param_list;
if (*pparam == NULL) {
- *pparam = (CSREMOTE_PROC_PARAM *)
malloc(sizeof(CSREMOTE_PROC_PARAM));
+ *pparam = param;
} else {
while ((*pparam)->next != NULL) {
pparam = &(*pparam)->next;
}
-
- (*pparam)->next = (CSREMOTE_PROC_PARAM *)
malloc(sizeof(CSREMOTE_PROC_PARAM));
- pparam = &(*pparam)->next;
}
- *pparam = param;
+ (*pparam)->next = param;
+ pparam = &(*pparam)->next;
(*pparam)->next = NULL;
tdsdump_log(TDS_DBG_INFO1, " ct_param() added rpc parameter %s
\n", (*param).name);
return CS_SUCCEED;
- [freetds] ct_param memory leak patch, Iain Calder, 01/15/2004
Archive powered by MHonArc 2.6.24.