Module: wine Branch: master Commit: e7d7ac77087ed33958047dae34a2e9d66c473c21 URL: https://gitlab.winehq.org/wine/wine/-/commit/e7d7ac77087ed33958047dae34a2e9d...
Author: Rémi Bernon rbernon@codeweavers.com Date: Fri Dec 15 18:46:17 2023 +0100
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)))