[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory leak in chan_capi



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
_______________________________________________
freebsd-isdn_(_at_)_freebsd_(_dot_)_org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isdn
To unsubscribe, send any mail to "freebsd-isdn-unsubscribe_(_at_)_freebsd_(_dot_)_org"


Visit your host, monkey.org