From 3a709e399ec6509bc332763270925bac16eeb0b7 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Fri, 3 Apr 2009 21:16:56 -0700 Subject: [PATCH] xkbcomp: Don't segfault if the debug files aren't set Another interface that needs to be cleaned up. --- src/xkbcomp/utils.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/xkbcomp/utils.c b/src/xkbcomp/utils.c index 55efbe1..34ba8e0 100644 --- a/src/xkbcomp/utils.c +++ b/src/xkbcomp/utils.c @@ -120,6 +120,9 @@ uEntry(int l, char *s, ...) int i; va_list args; + if (!entryFile) + return; + for (i = 0; i < uEntryLevel; i++) { putc(' ', entryFile); @@ -135,6 +138,9 @@ uExit(int l, char *rtVal) { int i; + if (!entryFile) + return; + uEntryLevel -= l; if (uEntryLevel < 0) uEntryLevel = 0; @@ -180,6 +186,9 @@ uDebug(char *s, ...) int i; va_list args; + if (!uDebugFile) + return; + for (i = (uDebugIndentLevel * uDebugIndentSize); i > 0; i--) { putc(' ', uDebugFile); @@ -195,6 +204,9 @@ uDebugNOI(char *s, ...) { va_list args; + if (!uDebugFile) + return; + va_start(args, s); vfprintf(uDebugFile, s, args); va_end(args); @@ -234,6 +246,9 @@ uInformation(const char *s, ...) { va_list args; + if (!errorFile) + return; + va_start(args, s); vfprintf(errorFile, s, args); va_end(args); @@ -247,6 +262,9 @@ uAction(const char *s, ...) { va_list args; + if (!errorFile) + return; + if (prefix != NULL) fprintf(errorFile, "%s", prefix); fprintf(errorFile, " "); @@ -263,6 +281,9 @@ uWarning(const char *s, ...) { va_list args; + if (!errorFile) + return; + if ((outCount == 0) && (preMsg != NULL)) fprintf(errorFile, "%s\n", preMsg); if (prefix != NULL) @@ -282,6 +303,9 @@ uError(const char *s, ...) { va_list args; + if (!errorFile) + return; + if ((outCount == 0) && (preMsg != NULL)) fprintf(errorFile, "%s\n", preMsg); if (prefix != NULL) @@ -301,6 +325,9 @@ uFatalError(const char *s, ...) { va_list args; + if (!errorFile) + return; + if ((outCount == 0) && (preMsg != NULL)) fprintf(errorFile, "%s\n", preMsg); if (prefix != NULL) @@ -323,6 +350,9 @@ uInternalError(const char *s, ...) { va_list args; + if (!errorFile) + return; + if ((outCount == 0) && (preMsg != NULL)) fprintf(errorFile, "%s\n", preMsg); if (prefix != NULL) @@ -360,7 +390,7 @@ uSetErrorPrefix(char *pre) void uFinishUp(void) { - if ((outCount > 0) && (postMsg != NULL)) + if (errorFile && (outCount > 0) && (postMsg != NULL)) fprintf(errorFile, "%s\n", postMsg); return; } -- 2.7.4