shithub: choc

Download patch

ref: c0bd4b7fe994820266af16ed44e368cc6e21389f
parent: a8a7ea27319ababa65d7753cc1aec3f37e955d4b
author: Fabian Greffrath <[email protected]>
date: Sun Jul 10 08:17:52 EDT 2016

do not naively assume singly-byte frame buffers

--- a/src/v_diskicon.c
+++ b/src/v_diskicon.c
@@ -55,7 +55,7 @@
     s = src; d = dest;
     for (y = 0; y < h; ++y)
     {
-        memcpy(d, s, w);
+        memcpy(d, s, w * sizeof(*d));
         s += src_pitch;
         d += dest_pitch;
     }
@@ -67,12 +67,12 @@
     patch_t *disk;
 
     // Allocate a complete temporary screen where we'll draw the patch.
-    tmpscreen = Z_Malloc(SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL);
-    memset(tmpscreen, 0, SCREENWIDTH * SCREENHEIGHT);
+    tmpscreen = Z_Malloc(SCREENWIDTH * SCREENHEIGHT * sizeof(*tmpscreen), PU_STATIC, NULL);
+    memset(tmpscreen, 0, SCREENWIDTH * SCREENHEIGHT * sizeof(*tmpscreen));
     V_UseBuffer(tmpscreen);
 
     // Buffer where we'll save the disk data.
-    disk_data = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H, PU_STATIC, NULL);
+    disk_data = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H * sizeof(*disk_data), PU_STATIC, NULL);
 
     // Draw the patch and save the result to disk_data.
     disk = W_CacheLumpName(disk_lump, PU_STATIC);
@@ -91,7 +91,7 @@
     loading_disk_xoffs = xoffs;
     loading_disk_yoffs = yoffs;
 
-    saved_background = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H, PU_STATIC,
+    saved_background = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H * sizeof(saved_background), PU_STATIC,
                                 NULL);
     SaveDiskData(lump_name, xoffs, yoffs);
 }