[freetds] memory leak in tds_alloc_dynamic
Roger Reynolds
rogerr at softix.com
Sun May 2 01:55:20 EDT 2004
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
More information about the FreeTDS
mailing list