A
ArifulHossain tuhin
My application is leaking memory in a memmove call. I have made it sure from coredumps.
the offending code snippet reads as follows:
unsigned char pad_len;
pad_len = (unsigned char)((random() % RANSTOP ) + RANSTART);
if(pad_len%30 == 0)
pad_len = 9;
if(packet->size > 0){
memmove(packet->data.buf + pad_len, packet->data.buf, packet->size);
packet->size += pad_len;
packet->data.buf[0] = pad_len;
for(j=1; j< pad_len; j++)
packet->data.buf[j] = (char)256%j;
EnDeCrypt(packet->data.buf, packet->size, key, KEYLEN);
}
the packet data structure is decalared as follows:
struct rtp_packet {
size_t size;
................
(some fields)
................
struct rtp_packet *next;
struct rtp_packet *prev;
union {
rtp_hdr_t header;
unsigned char buf[8192];
} data;
};
As the data.buf is statically allocated, valgrind does not complain anything about it.
Is it running out of memory? or any other problem?
Any suggestion?
the offending code snippet reads as follows:
unsigned char pad_len;
pad_len = (unsigned char)((random() % RANSTOP ) + RANSTART);
if(pad_len%30 == 0)
pad_len = 9;
if(packet->size > 0){
memmove(packet->data.buf + pad_len, packet->data.buf, packet->size);
packet->size += pad_len;
packet->data.buf[0] = pad_len;
for(j=1; j< pad_len; j++)
packet->data.buf[j] = (char)256%j;
EnDeCrypt(packet->data.buf, packet->size, key, KEYLEN);
}
the packet data structure is decalared as follows:
struct rtp_packet {
size_t size;
................
(some fields)
................
struct rtp_packet *next;
struct rtp_packet *prev;
union {
rtp_hdr_t header;
unsigned char buf[8192];
} data;
};
As the data.buf is statically allocated, valgrind does not complain anything about it.
Is it running out of memory? or any other problem?
Any suggestion?