From: Mike F. <va...@ge...> - 2007-04-02 11:58:21
|
On Monday 02 April 2007, Subrata Modak1 wrote: > The Unix98 standard requires malloc() to set errno to ENOMEM upon failure. that whole description of malloc, while informative, is irrelevant here ...= =20 nowhere is errno being checked by the stack_space.c test. the error is tha= t=20 the bits calculation comes out to 0 and while glibc will go ahead and=20 allocate some memory for you anyways, other implementations will return NUL= L=20 (which is saner imo and certainly valid according to POSIX). so on any system (like uClibc) where malloc(0) returns NULL, stack_space wi= ll=20 bail early claiming malloc() failed: bits =3D (char*)malloc((nchunks+7)/8); val_buf =3D (char*)(malloc(csize)); zero_buf =3D (char*)(malloc(csize)); if (bits =3D=3D 0 || val_buf =3D=3D 0 || zero_buf =3D=3D 0) { tst_resm(TFAIL, "\tmalloc failed, pid: %d\n",getpid()); tst_exit(); } =2Dmike |