Переглянути джерело

Crash on localtime struct

Seems localtime struct ptr is not being returned, thus we crash (might be something with my environment), however for now adding a check to stop us from crashing.
Image 4 роки тому
батько
коміт
e5876f9a10

+ 6 - 1
EQ2/source/common/EQPacket.cpp

@@ -138,7 +138,12 @@ void EQPacket::DumpRawHeader(uint16 seq, FILE *to) const
 {
 	if (timestamp.tv_sec) {
 		char temp[20];
-		strftime(temp,20,"%F %T",localtime((const time_t *)&timestamp.tv_sec));
+		struct tm* info = localtime((const time_t*)&timestamp.tv_sec);
+		if (info)
+			strftime(temp, 20, "%F %T", info);
+		else
+			_snprintf(temp, 20, "[UNKNOWNTIME]");
+
 		fprintf(to, "%s.%06lu ",temp,timestamp.tv_usec);
 	}
 	if (src_ip) {

BIN
server/EQ2Login__Debug.exe


BIN
server/EQ2World__Debug.exe


BIN
server/EQ2World__Debug_x64.exe