Skip to Content.
Sympa Menu

freetds - RE: [freetds] memory leak in tds_alloc_dynamic

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Roger Reynolds <rogerr AT softix.com>
  • To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] memory leak in tds_alloc_dynamic
  • Date: Sun, 2 May 2004 15:55:20 +1000


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





Archive powered by MHonArc 2.6.24.

Top of Page