File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -297,6 +297,7 @@ void Sys_PrintLog( const char *pMsg )
297
297
const struct tm * crt_tm ;
298
298
char logtime [32 ] = "" ;
299
299
static char lastchar ;
300
+ size_t len ;
300
301
301
302
time ( & crt_time );
302
303
crt_tm = localtime ( & crt_time );
@@ -307,18 +308,20 @@ void Sys_PrintLog( const char *pMsg )
307
308
// spew to stdout
308
309
Sys_PrintStdout ( logtime , pMsg );
309
310
311
+ len = Q_strlen ( pMsg );
312
+
310
313
if ( !s_ld .logfile )
311
314
{
312
315
// save last char to detect when line was not ended
313
- lastchar = pMsg [ Q_strlen ( pMsg ) - 1 ];
316
+ lastchar = len > 0 ? pMsg [ len - 1 ] : 0 ;
314
317
return ;
315
318
}
316
319
317
320
if ( !lastchar || lastchar == '\n' )
318
321
strftime ( logtime , sizeof ( logtime ), "[%Y:%m:%d|%H:%M:%S] " , crt_tm ); //full time
319
322
320
323
// save last char to detect when line was not ended
321
- lastchar = pMsg [ Q_strlen ( pMsg ) - 1 ];
324
+ lastchar = len > 0 ? pMsg [ len - 1 ] : 0 ;
322
325
323
326
Sys_PrintLogfile ( s_ld .logfileno , logtime , pMsg , false );
324
327
Sys_FlushLogfile ();
You can’t perform that action at this time.
0 commit comments