[prev in list] [next in list] [prev in thread] [next in thread]
List: asterisk-bsd
Subject: [Asterisk-bsd] Memory leak in chan_capi
From: Hans Petter Selasky <hselasky () c2i ! net>
Date: 2005-08-04 11:41:39
Message-ID: 200508041341.40949.hselasky () c2i ! net
[Download RAW message or body]
Hi,
I think there is a memory leak in chan_capi, if anyone is using it.
Memory is duplicated with strdup, but never freed. Solution: use alloca().
Here is a patch:
enum { max_telno = 256 }; /* including terminating zero */
static char *capi_number(u_int8_t *data, int strip, u_int8_t *buf) {
#define capi_number(data,strip) capi_number(data,strip,(u_int8_t
*)alloca(max_telno))
u_int16_t len;
/* convert a CAPI structure into a
* zero terminated string
*/
if(data[0] == 0xFF)
{
len = data[1]|(data[2] << 8);
data += 3;
}
else
{
len = data[0];
data += 1;
}
if(len >= max_telno)
len = max_telno-1;
bcopy(data, buf, len);
buf[len] = 0;
return (char *)buf;
}
--HPS
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic