Handle memory allocation errors
Exit with return code 1 if memory allocation fails instead of just issuing a warning and resume execution with bogus pointer values. Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
@ -71,11 +71,10 @@ char *ptr;
|
|||||||
ptr=(char *)malloc(size);
|
ptr=(char *)malloc(size);
|
||||||
if (ptr==NULL) {
|
if (ptr==NULL) {
|
||||||
fprintf(stderr,"%s: Out of memory\n",myname);
|
fprintf(stderr,"%s: Out of memory\n",myname);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return(ptr);
|
return(ptr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int badsuffix(path,suffix)
|
int badsuffix(path,suffix)
|
||||||
char *path;
|
char *path;
|
||||||
|
Reference in New Issue
Block a user