[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

More bugs in MiNT 1.09



zero() can produce an address error on an 68000 when the size of the
block is uneven.

load_region() can pass a non-word-aligned block to zero().

--- orig/mem.c	Tue Aug 17 21:23:24 1993
+++ mem.c	Sat Sep  4 22:56:22 1993
@@ -1145,7 +1145,18 @@
 		size = b->p_blen;
 	else
 		size = b->p_hitpa - b->p_bbase;
-	zero((char *)b->p_bbase, size);
+	if (size > 0)
+	  {
+	    /* the block passed to zero() must be word-aligned! */
+	    start = b->p_bbase;
+	    if (start & 1)
+	      {
+		*(char *) start = 0;
+		start++;
+		size--;
+	      }
+	    zero((char *)start, size);
+	  }
 
 	do_close(f);
 	*text = shtext;
--- orig/util.c	Tue Aug 17 21:23:28 1993
+++ util.c	Sat Sep  4 22:40:34 1993
@@ -81,13 +81,14 @@
 
 	cruft = size % 256;	/* quickzero does 256 byte blocks */
 	size = size / 256;
+	if (size > 0) {
+		quickzero(place, size);
+		place += size * 256;
+	}
 	while (cruft > 0) {
 		*place++ = 0;
 		cruft--;
 	}
-	if (size > 0) {
-		quickzero(place, size);
-	}
 }
 
 #ifdef JUNK_MEM