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: Tue, 4 May 2004 14:18:53 +1000


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




Archive powered by MHonArc 2.6.24.

Top of Page