diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2010-04-09 13:29:38 +0400 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2010-04-10 00:02:46 +0400 |
commit | 9b60308282d888b3fb4623900d508b0176d94c4f (patch) | |
tree | 06eca8842c42a0bc5388de5de3b64a1b4663de0e /nasmlib.c | |
parent | 572dd0021c250fa371e525260787e382701586fa (diff) | |
download | nasm-9b60308282d888b3fb4623900d508b0176d94c4f.tar.gz nasm-9b60308282d888b3fb4623900d508b0176d94c4f.tar.bz2 nasm-9b60308282d888b3fb4623900d508b0176d94c4f.zip |
nasmlib: Do not hang on if log file creation has been failed
In case if we can't open "malloc.log" for writing
we should not hang out but rather switch to stderr
and continue processing.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'nasmlib.c')
-rw-r--r-- | nasmlib.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2009 The NASM Authors - All Rights Reserved + * Copyright 1996-2010 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -90,7 +90,12 @@ void nasm_init_malloc_error(void) { #ifdef LOGALLOC logfp = fopen("malloc.log", "w"); - setvbuf(logfp, NULL, _IOLBF, BUFSIZ); + if (logfp) { + setvbuf(logfp, NULL, _IOLBF, BUFSIZ); + } else { + nasm_error(ERR_NONFATAL | ERR_NOFILE, "Unable to open %s", file); + logfp = stderr; + } fprintf(logfp, "null pointer is %p\n", NULL); #endif } |