Код: Выделить всё
int WriteToFD(int *fd,u_int8_t **buf,int buf_size,int *bc,long *usec)
{
struct timeval *slice;
fd_set fds;
int flag,j,errsv;
long eta;
*bc=0;
if (usec)
{
slice=(struct timeval *)malloc(sizeof(struct timeval));
slice->tv_sec=0;
slice->tv_usec=(*usec);
eta=(*usec);
}
else
{
slice=NULL; //Be care. It's infinity
}
j=0;
//SKIPPED
//.....
flag=select(*fd+1,NULL,&fds,NULL,slice);
//SKIPPED
//.....
if (slice)
free(slice);
return 0;
//SKIPPED
//.....
}При вызове этой процедуры у заказчика возникает ошибка вида
***glibc detected free() invalid next size
, при выходе из функции
Если изменить строку 'slice=(struct timeval *)malloc(sizeof(struct timeval));' на 'slice=(struct timeval *)malloc(1024);', то ошибка изменяется
на ***glibc detected double free() or corruption.
Установленная система Slackware linux 11, linux-2.6.17.13-smp, glibc-2.3.6
Железо PentiumD, RAM 1Gb
На других системах все работает, как часы (как на более старых, так и на более новых)
С чем это может быть связано?