From: Cyrill Gorcunov Date: Fri, 9 Apr 2010 09:29:38 +0000 (+0400) Subject: nasmlib: Do not hang on if log file creation has been failed X-Git-Tag: nasm-2.11.05~687 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b60308282d888b3fb4623900d508b0176d94c4f;p=platform%2Fupstream%2Fnasm.git 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 --- diff --git a/nasmlib.c b/nasmlib.c index 550c42d..2351101 100644 --- a/nasmlib.c +++ b/nasmlib.c @@ -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 }