comparison svr-session.c @ 404:a588558bfc94

Fix potential null pointer dereference found by Klokwork
author Matt Johnston <matt@ucc.asn.au>
date Sat, 03 Feb 2007 09:58:14 +0000
parents 3be7ae2e8dfa
children c216212001fc
comparison
equal deleted inserted replaced
403:75940fef22dd 404:a588558bfc94
179 havetrace = debug_trace; 179 havetrace = debug_trace;
180 #endif 180 #endif
181 181
182 if (!svr_opts.usingsyslog || havetrace) 182 if (!svr_opts.usingsyslog || havetrace)
183 { 183 {
184 struct tm * local_tm = NULL;
184 timesec = time(NULL); 185 timesec = time(NULL);
185 if (strftime(datestr, sizeof(datestr), "%b %d %H:%M:%S", 186 local_tm = localtime(&timesec);
186 localtime(&timesec)) == 0) { 187 if (local_tm == NULL
187 datestr[0] = '?'; datestr[1] = '\0'; 188 || strftime(datestr, sizeof(datestr), "%b %d %H:%M:%S",
189 localtime(&timesec)) == 0)
190 {
191 // upon failure, just print the epoch-seconds time.
192 snprintf(datestr, sizeof(datestr), "%d", timesec);
188 } 193 }
189 fprintf(stderr, "[%d] %s %s\n", getpid(), datestr, printbuf); 194 fprintf(stderr, "[%d] %s %s\n", getpid(), datestr, printbuf);
190 } 195 }
191 } 196 }
192 197