Explorar o código

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 %!s(int64=4) %!d(string=hai) anos
pai
achega
e5876f9a10
Modificáronse 4 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      EQ2/source/common/EQPacket.cpp
  2. BIN=BIN
      server/EQ2Login__Debug.exe
  3. BIN=BIN
      server/EQ2World__Debug.exe
  4. BIN=BIN
      server/EQ2World__Debug_x64.exe

+ 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=BIN
server/EQ2Login__Debug.exe


BIN=BIN
server/EQ2World__Debug.exe


BIN=BIN
server/EQ2World__Debug_x64.exe