$NetBSD: patch-ai,v 1.1 2005/10/03 17:52:10 joerg Exp $ --- lib/common/debug.c.orig 2005-08-16 19:40:17.000000000 +0000 +++ lib/common/debug.c @@ -110,7 +110,7 @@ int debug_disable_warnings = 0; /*** Private Function Prototype Declarations ****/ /*** Private Variable Declarations ***/ -static FILE *__rsd_debug_file = stdout; +static FILE *__rsd_debug_file = NULL; /***** * When debug output is send to a file, we register an exit func to close @@ -128,7 +128,8 @@ __rsd_at_exit(void) #endif { /* close output file */ - fclose(__rsd_debug_file); + if (__rsd_debug_file != NULL) + fclose(__rsd_debug_file); } /***** @@ -159,6 +160,9 @@ __rsd_fprintf(fmt, va_alist) va_start(arg_list); #endif /* __STDC__ */ + if (__rsd_debug_file == NULL) + __rsd_debug_file = stdout; + /* flush to file */ vfprintf(__rsd_debug_file, fmt, arg_list); va_end(arg_list); @@ -298,7 +302,7 @@ __rsd_setDebugLevels(int *argc, char **a if((chPtr = strstr(argv[i], ":")) != NULL) { /* close any existing output file */ - if(__rsd_debug_file != stdout) + if(__rsd_debug_file != stdout && __rsd_debug_file != NULL) fclose(__rsd_debug_file); chPtr++; /* skip : */