[Scummvm-cvs-logs] CVS: scummvm/saga animation.cpp,1.14,1.15

Jonathan Gray khalek at users.sourceforge.net
Sun Aug 1 01:46:07 CEST 2004


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15603

Modified Files:
	animation.cpp 
Log Message:
try to stop the abuse of MemoryReadStream (ie actually delete the memory when we're done with it)

Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/animation.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- animation.cpp	1 Aug 2004 07:32:27 -0000	1.14
+++ animation.cpp	1 Aug 2004 08:45:40 -0000	1.15
@@ -376,6 +376,7 @@
 	if (GAME_GetGameType() == R_GAMETYPE_IHNM) {
 		*n_frames = ah.nframes;
 	}
+	delete readS;
 
 	if (ah.magic == 68) {
 		for (x = ah.nframes; x > 0; x--) {
@@ -440,6 +441,8 @@
 	screen_w = ah.screen_w;
 	screen_h = ah.screen_h;
 
+	delete readS;
+
 	if ((screen_w * screen_h) > buf_len) {
 		// Buffer argument is too small to hold decoded frame, abort.
 		warning("ITE_DecodeFrame: Buffer size inadequate");
@@ -453,6 +456,7 @@
 	magic = readS->readByte();
 	if (magic != SAGA_FRAME_HEADER_MAGIC) {
 		warning("ITE_DecodeFrame: Invalid frame offset");
+		delete readS;
 		return R_FAILURE;
 	}
 
@@ -510,6 +514,7 @@
 			continue;
 			break;
 		case 0x3F: // End of frame marker
+			delete readS;
 			return R_SUCCESS;
 			break;
 		default:
@@ -550,11 +555,13 @@
 		default:
 			// Unknown marker found - abort
 			warning("ITE_DecodeFrame: Invalid RLE marker encountered");
+			delete readS;
 			return R_FAILURE;
 			break;
 		}
 	} while (mark_byte != 63); // end of frame marker
 
+	delete readS;
 	return R_SUCCESS;
 }
 
@@ -622,6 +629,7 @@
 				if (outbuf_p > outbuf_endp) {
 					warning("0x%02X: (0x%X) Invalid output position. (x: %d, y: %d)",
 							in_ch, in_ch_offset, x_origin, y_origin);
+					delete readS;
 					return R_FAILURE;
 				}
 
@@ -633,10 +641,12 @@
 			runcount = readS->readSint16BE();
 			if (thisf_len - readS->pos() < runcount) {
 				warning("0x%02X: Input buffer underrun", in_ch);
+				delete readS;
 				return R_FAILURE;
 			}
 			if (outbuf_remain < runcount) {
 				warning("0x%02X: Output buffer overrun", in_ch);
+				delete readS;
 				return R_FAILURE;
 			}
 
@@ -654,6 +664,7 @@
 		case 0x1F: // 31: Unusued?
 			if (thisf_len - readS->pos() < 3) {
 				warning("0x%02X: Input buffer underrun", in_ch);
+				delete readS;
 				return R_FAILURE;
 			}
 
@@ -665,6 +676,7 @@
 		case 0x20: // Long compressed run
 			if (thisf_len - readS->pos() <= 3) {
 				warning("0x%02X: Input buffer underrun", in_ch);
+				delete readS;
 				return R_FAILURE;
 			}
 
@@ -681,6 +693,7 @@
 
 		case 0x2F: // End of row
 			if (thisf_len - readS->pos() <= 4) {
+				delete readS;
 				return R_FAILURE;
 			}
 
@@ -693,6 +706,7 @@
 			break;
 		case 0x30: // Reposition command
 			if (thisf_len - readS->pos() < 2) {
+				delete readS;
 				return R_FAILURE;
 			}
 
@@ -700,6 +714,7 @@
 
 			if (((x_vector > 0) && ((size_t) x_vector > outbuf_remain)) || (-x_vector > outbuf_p - decode_buf)) {
 				warning("0x30: Invalid x_vector");
+				delete readS;
 				return R_FAILURE;
 			}
 
@@ -733,6 +748,7 @@
 		case 0xC0: // Run of empty pixels
 			runcount = param_ch + 1;
 			if (outbuf_remain < runcount) {
+				delete readS;
 				return R_FAILURE;
 			}
 
@@ -743,6 +759,7 @@
 		case 0x80: // Run of compressed data
 			runcount = param_ch + 1;
 			if ((outbuf_remain < runcount) || (thisf_len - readS->pos() <= 1)) {
+				delete readS;
 				return R_FAILURE;
 			}
 
@@ -758,6 +775,7 @@
 		case 0x40: // Uncompressed run
 			runcount = param_ch + 1;
 			if ((outbuf_remain < runcount) || (thisf_len - readS->pos() < runcount)) {
+				delete readS;
 				return R_FAILURE;
 			}
 
@@ -778,6 +796,7 @@
 			break;
 		}
 	}
+	delete readS;
 
 	return R_SUCCESS;
 }
@@ -822,6 +841,7 @@
 		magic = readS->readByte();
 		if (magic != SAGA_FRAME_HEADER_MAGIC) {
 			// Frame sync failure. Magic Number not found
+			delete readS;
 			return R_FAILURE;
 		}
 
@@ -894,6 +914,7 @@
 	}
 
 	*frame_offset_p = readS->pos();
+	delete readS;
 	return R_SUCCESS;
 }
 





More information about the Scummvm-git-logs mailing list