From e7d7ac77087ed33958047dae34a2e9d66c473c21 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Bernon?= Date: Fri, 15 Dec 2023 18:46:17 +0100 Subject: [PATCH] wined3d: Add more padding to resource memory allocations. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55773 --- dlls/wined3d/resource.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 9d3fd0a426d..5351fbd3025 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -332,7 +332,11 @@ void CDECL wined3d_resource_preload(struct wined3d_resource *resource) static BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) { void **p; - SIZE_T align = RESOURCE_ALIGNMENT - 1 + sizeof(*p); + /* Overallocate and add padding to the allocated pointer, to guard against + * games (for instance Railroad Tycoon 2) writing before the locked resource + * memory pointer. + */ + SIZE_T align = RESOURCE_ALIGNMENT + sizeof(*p); void *mem; if (!(mem = heap_alloc_zero(resource->size + align))) -- 2.11.4.GIT