[freetds] memory leak in tds_alloc_dynamic
Roger Reynolds
rogerr at softix.com
Tue May 4 00:18:53 EDT 2004
Hello Group,
I sent this message in a couple days ago, and haven't heard
any reply from the group so I thought I'd try again.
It's kinda sorta important to me that this change get incorporated
into the official code base, so please let me know what I can
do to facilitate that.
Thanks.
-----Original Message-----
From: Roger Reynolds [mailto:rogerr at softix.com]
Sent: Sunday, May 02, 2004 3:55 PM
To: 'FreeTDS Development Group'
Subject: RE: [freetds] memory leak in tds_alloc_dynamic
Hello there.
I have noticed a memory leak in the tds_alloc_dynamic routine.
This happens whenever the only open statement atainst the
connection is freed, and tds_free_dynamic decrements tds->num_dyns to 0,
but does not free the tds->dyns pointer.
If you come along and subsequently call tds_alloc_dynamic on
the same tds_socket, then you leak memory when the check for
if (!tds->num_dyns)
sees it as 0 and allocates a new tds buffer for tds->dyns.
The fix would be to either change this test to
if (!tds->dyns)
or, in tds_free_dynamic to add something like this
if (tds->num_dyns == 0 && tds->dyns) {
free(tds->dyns);
tds->dyns = 0;
}
after freeing the specified dyn and decrementing tds->num_dyns.
Of course, I have studied the internals of tds for all of about
10 minutes now, so I could be completely off my rocker here:)
Thanks in advance for tending to this...
roger
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
More information about the FreeTDS
mailing list