Browse Source

Code to investigate issue #163

Code to help identify issue #163
image 3 years ago
parent
commit
e9cd846d27
2 changed files with 14 additions and 1 deletions
  1. 10 0
      EQ2/source/common/EQPacket.cpp
  2. 4 1
      EQ2/source/common/misc.cpp

+ 10 - 0
EQ2/source/common/EQPacket.cpp

@@ -498,6 +498,16 @@ uint32 flag_offset=0;
 	if (length>2 && buffer[flag_offset]==0x5a)  {
 		LogWrite(PACKET__DEBUG, 0, "Packet", "In Decompress 1");
 		newlen=Inflate(const_cast<unsigned char *>(buffer+flag_offset+1),length-(flag_offset+1)-2,newbuf+flag_offset,newbufsize-flag_offset)+2;
+
+		// something went bad with zlib
+		if (newlen == -1)
+		{
+			LogWrite(PACKET__ERROR, 0, "Packet", "Debug Bad Inflate!");
+			DumpPacket(buffer, length);
+			memcpy(newbuf, buffer, length);
+			return length;
+		}
+
 		newbuf[newlen++]=buffer[length-2];
 		newbuf[newlen++]=buffer[length-1];
 	} else if (length>2 && buffer[flag_offset]==0xa5) {

+ 4 - 1
EQ2/source/common/misc.cpp

@@ -132,7 +132,10 @@ int i;
 			cout << "'" << endl;
 		}
 		
-		if (zerror == -4 && zstream.msg == 0)
+		if (zerror == Z_DATA_ERROR || zerror == Z_ERRNO)
+			return -1;
+
+		if (zerror == Z_MEM_ERROR && zstream.msg == 0)
 		{
 			return 0;
 		}