From fd06fbe1438031bac0e539a9c8284de35468393b Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka <cmatsuoka@gmail.com> Date: Mon, 10 Jan 2011 08:12:28 -0200 Subject: [PATCH] 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> --- chkfont.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/chkfont.c b/chkfont.c index 884b6cc..26e4606 100644 --- a/chkfont.c +++ b/chkfont.c @@ -71,10 +71,9 @@ char *ptr; ptr=(char *)malloc(size); if (ptr==NULL) { fprintf(stderr,"%s: Out of memory\n",myname); + exit(1); } -else { - return(ptr); - } +return(ptr); } int badsuffix(path,suffix)