Date: Thu, 4 Aug 2005 13:41:39 +0200 From: Hans Petter Selasky <hselasky@c2i.net> To: asterisk-bsd@lists.digium.com, freebsd-isdn@freebsd.org Subject: Memory leak in chan_capi Message-ID: <200508041341.40949.hselasky@c2i.net>
next in thread | raw e-mail | index | archive | help
Hi,=20 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 =3D 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=20 *)alloca(max_telno)) =A0 =A0u_int16_t len; =A0 =A0/* convert a CAPI structure into a=20 =A0 =A0 * zero terminated string=20 =A0 =A0 */ =A0 =A0if(data[0] =3D=3D 0xFF) =A0 =A0{ =A0 =A0 =A0 len =3D data[1]|(data[2] << 8); =A0 =A0 =A0 data +=3D 3; =A0 =A0} =A0 =A0else =A0 =A0{ =A0 =A0 =A0 len =3D data[0]; =A0 =A0 =A0 data +=3D 1; =A0 =A0} =A0 =A0if(len >=3D max_telno) =A0 =A0 =A0 len =3D max_telno-1; =A0 =A0bcopy(data, buf, len); =A0 =A0buf[len] =3D 0; =A0 =A0return (char *)buf; } =2D-HPS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508041341.40949.hselasky>