From: Tomas Hozza Date: Fri, 26 Apr 2013 12:42:30 +0000 (+0200) Subject: Fix using deadcode and possible use of NULL pointer X-Git-Tag: v1.15~44 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=c9c0e4c6418350d913638d73e0a50bebdb5fd983 Fix using deadcode and possible use of NULL pointer Fix for deadcode in unique_create() so that "opened_name" parameter is always initialized to a valid string or NULL when returning from function. Fix for redirect_output() so that "logfile" is not blindly used in fprintf() call and checked if it is not NULL. Signed-off-by: Tomas Hozza --- diff --git a/src/ChangeLog b/src/ChangeLog index 02409762..5b978ebb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2013-04-26 Tomas Hozza (tiny change) + + * log.c (redirect_output): Use DEFAULT_LOGFILE in diagnostic message + when `logfile' is NULL. + * utils.c (unique_create): Ensure `logfile' has always a value. + 2013-06-26 Darshit Shah * http.c (gethttp): Reverse change by commit 90896 that prevented diff --git a/src/log.c b/src/log.c index 0185df19..4f93a21c 100644 --- a/src/log.c +++ b/src/log.c @@ -871,7 +871,7 @@ redirect_output (void) can do but disable printing completely. */ fprintf (stderr, _("\n%s received.\n"), redirect_request_signal_name); fprintf (stderr, _("%s: %s; disabling logging.\n"), - logfile, strerror (errno)); + (logfile) ? logfile : DEFAULT_LOGFILE, strerror (errno)); inhibit_logging = true; } save_context_p = false; diff --git a/src/utils.c b/src/utils.c index f87853dc..2ec96018 100644 --- a/src/utils.c +++ b/src/utils.c @@ -703,7 +703,7 @@ unique_create (const char *name, bool binary, char **opened_name) xfree (uname); uname = unique_name (name, false); } - if (opened_name && fp != NULL) + if (opened_name) { if (fp) *opened_name = uname;