shithub: choc

Download patch

ref: 6345a9bdee69210df5979bac2ea766a25ea1f613
parent: d368801835fb910b5e642fa9d89ad7673f4bea27
author: Fabian Greffrath <[email protected]>
date: Tue Nov 17 06:13:31 EST 2015

Do not blindly assume single-byte framebuffers

--- a/src/doom/am_map.c
+++ b/src/doom/am_map.c
@@ -833,7 +833,7 @@
 //
 void AM_clearFB(int color)
 {
-    memset(fb, color, f_w*f_h);
+    memset(fb, color, f_w*f_h*sizeof(*fb));
 }
 
 
--- a/src/doom/f_wipe.c
+++ b/src/doom/f_wipe.c
@@ -67,7 +67,7 @@
   int	height,
   int	ticks )
 {
-    memcpy(wipe_scr, wipe_scr_start, width*height);
+    memcpy(wipe_scr, wipe_scr_start, width*height*sizeof(*wipe_scr));
     return 0;
 }
 
@@ -138,7 +138,7 @@
     int i, r;
     
     // copy start screen to main screen
-    memcpy(wipe_scr, wipe_scr_start, width*height);
+    memcpy(wipe_scr, wipe_scr_start, width*height*sizeof(*wipe_scr));
     
     // makes this wipe faster (in theory)
     // to have stuff in column-major format
@@ -234,7 +234,7 @@
   int	width,
   int	height )
 {
-    wipe_scr_start = Z_Malloc(SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL);
+    wipe_scr_start = Z_Malloc(SCREENWIDTH * SCREENHEIGHT * sizeof(*wipe_scr_start), PU_STATIC, NULL);
     I_ReadScreen(wipe_scr_start);
     return 0;
 }
@@ -246,7 +246,7 @@
   int	width,
   int	height )
 {
-    wipe_scr_end = Z_Malloc(SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL);
+    wipe_scr_end = Z_Malloc(SCREENWIDTH * SCREENHEIGHT * sizeof(*wipe_scr_end), PU_STATIC, NULL);
     I_ReadScreen(wipe_scr_end);
     V_DrawBlock(x, y, width, height, wipe_scr_start); // restore start scr.
     return 0;
--- a/src/doom/r_draw.c
+++ b/src/doom/r_draw.c
@@ -843,7 +843,7 @@
 	
     if (background_buffer == NULL)
     {
-        background_buffer = Z_Malloc(SCREENWIDTH * (SCREENHEIGHT - SBARHEIGHT),
+        background_buffer = Z_Malloc(SCREENWIDTH * (SCREENHEIGHT - SBARHEIGHT) * sizeof(*background_buffer),
                                      PU_STATIC, NULL);
     }
 
@@ -928,7 +928,7 @@
 
     if (background_buffer != NULL)
     {
-        memcpy(I_VideoBuffer + ofs, background_buffer + ofs, count); 
+        memcpy(I_VideoBuffer + ofs, background_buffer + ofs, count * sizeof(*I_VideoBuffer));
     }
 } 
 
--- a/src/doom/st_stuff.c
+++ b/src/doom/st_stuff.c
@@ -1430,6 +1430,6 @@
 void ST_Init (void)
 {
     ST_loadData();
-    st_backing_screen = (byte *) Z_Malloc(ST_WIDTH * ST_HEIGHT, PU_STATIC, 0);
+    st_backing_screen = (byte *) Z_Malloc(ST_WIDTH * ST_HEIGHT * sizeof(*st_backing_screen), PU_STATIC, 0);
 }
 
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1020,7 +1020,7 @@
 //
 void I_ReadScreen (byte* scr)
 {
-    memcpy(scr, I_VideoBuffer, SCREENWIDTH*SCREENHEIGHT);
+    memcpy(scr, I_VideoBuffer, SCREENWIDTH*SCREENHEIGHT*sizeof(*scr));
 }
 
 
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -110,7 +110,7 @@
 
     for ( ; height>0 ; height--) 
     { 
-        memcpy(dest, src, width); 
+        memcpy(dest, src, width * sizeof(*dest));
         src += SCREENWIDTH; 
         dest += SCREENWIDTH; 
     } 
@@ -520,7 +520,7 @@
 
     while (height--) 
     { 
-	memcpy (dest, src, width); 
+	memcpy (dest, src, width * sizeof(*dest));
 	src += width; 
 	dest += SCREENWIDTH; 
     }