[Scummvm-cvs-logs] SF.net SVN: scummvm:[40930] scummvm/trunk/engines/sci/engine

waltervn at users.sourceforge.net waltervn at users.sourceforge.net
Wed May 27 01:34:57 CEST 2009


Revision: 40930
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40930&view=rev
Author:   waltervn
Date:     2009-05-26 23:34:57 +0000 (Tue, 26 May 2009)

Log Message:
-----------
SCI: Changed signatures of StrLen and StrCpy to allow NULL pointers. This is
needed for a game bug in KQ6CD.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kstring.cpp

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-05-26 21:16:48 UTC (rev 40929)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-05-26 23:34:57 UTC (rev 40930)
@@ -141,8 +141,8 @@
 	/*47*/	DEFUN("StrEnd", kStrEnd, "r"),
 	/*48*/	DEFUN("StrCat", kStrCat, "rr"),
 	/*49*/	DEFUN("StrCmp", kStrCmp, "rri*"),
-	/*4a*/	DEFUN("StrLen", kStrLen, "r"),
-	/*4b*/	DEFUN("StrCpy", kStrCpy, "rri*"),
+	/*4a*/	DEFUN("StrLen", kStrLen, "Zr"),
+	/*4b*/	DEFUN("StrCpy", kStrCpy, "rZri*"),
 	/*4c*/	DEFUN("Format", kFormat, "r.*"),
 	/*4d*/	DEFUN("GetFarText", kGetFarText, "iir"),
 	/*4e*/	DEFUN("ReadNumber", kReadNumber, "r"),
@@ -923,6 +923,9 @@
 	int maxsize;
 	void *retval = s->seg_manager->dereference(pointer, &maxsize);
 
+	if (!retval)
+		return NULL;
+
 	if (pointer.offset & (align - 1)) {
 		warning("Unaligned pointer read: %04x:%04x expected with %d alignment", PRINT_REG(pointer), align);
 		return NULL;

Modified: scummvm/trunk/engines/sci/engine/kstring.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kstring.cpp	2009-05-26 21:16:48 UTC (rev 40929)
+++ scummvm/trunk/engines/sci/engine/kstring.cpp	2009-05-26 23:34:57 UTC (rev 40930)
@@ -296,7 +296,8 @@
 	if (!src) {
 		warning("Attempt to strcpy FROM invalid pointer %04x:%04x",
 		          PRINT_REG(argv[1]));
-		return NULL_REG;
+		*dest = 0;
+		return argv[1];
 	}
 
 	if (argc > 2) {
@@ -632,6 +633,11 @@
 reg_t kStrLen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	char *str = kernel_dereference_char_pointer(s, argv[0], 0);
 
+	if (!str) {
+		warning("StrLen: invalid pointer %04x:%04x", PRINT_REG(argv[0]));
+		return NULL_REG;
+	}
+
 	return make_reg(0, strlen(str));
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list