Skip to Content.
Sympa Menu

freetds - [freetds] [PATCH] ctlib: ct_param memory leaks, stored proc return status

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Iain Calder <iain.calder AT blueyonder.co.uk>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] [PATCH] ctlib: ct_param memory leaks, stored proc return status
  • Date: Mon, 12 Apr 2004 23:48:06 +0100

I have posted this patch before but it does not seem to have made it into production. Thanks to Bill Thompson for help with the return status fix.

Diff is against latest snapshot.


--- freetds-0.63.dev.20040412/src/ctlib/ct.c 2004-02-03 19:28:10.000000000 +0000
+++ freetds-0.63.dev.20040412.new/src/ctlib/ct.c 2004-04-12 23:31:26.000000000 +0100
@@ -1462,6 +1462,12 @@
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;
@@ -2674,16 +2680,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;
@@ -3171,11 +3175,13 @@
{
TDSRESULTINFO *info;
TDSCOLUMN *curcol;
+ TDS_INT saved_status;

enum
{ num_cols = 1 };

assert(tds);
+ saved_status = tds->ret_status;
tds_free_all_results(tds);

/* allocate the columns structure */
@@ -3202,7 +3208,7 @@

assert(0 <= curcol->column_offset && curcol->column_offset < info->row_size);

- *(TDS_INT *) (info->current_row + curcol->column_offset) = tds->ret_status;
+ *(TDS_INT *) (info->current_row + curcol->column_offset) = saved_status;

return TDS_SUCCEED;
}




Archive powered by MHonArc 2.6.24.

Top of Page