wined3d: Ensure that wined3d_cs_st_require_space allocates the required space
Sebastian Lackner
sebastian at fds-team.de
Tue Oct 1 13:07:05 CDT 2013
The current implementation of wined3d_cs_st_require_space just doubles
the previous buffer size, but doesn't ensure that this is really sufficient:
> if (!(new_data = HeapReAlloc(GetProcessHeap(), 0, cs->data,
cs->data_size * 2)))
This patch adds a while() loop to ensure that the buffer is big enough.
---
dlls/wined3d/cs.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
-------------- next part --------------
>From fd160b79c48fc20ae383450d9d9fe09a7280b465 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian at fds-team.de>
Date: Tue, 1 Oct 2013 19:58:54 +0200
Subject: wined3d: Ensure that wined3d_cs_st_require_space allocates the
required space
---
dlls/wined3d/cs.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index b9f2929..28333f2 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -212,11 +212,16 @@ static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size)
if (size > cs->data_size)
{
void *new_data;
+ size_t new_size;
- if (!(new_data = HeapReAlloc(GetProcessHeap(), 0, cs->data, cs->data_size * 2)))
+ new_size = cs->data_size * 2;
+ while (size > new_size)
+ new_size *= 2;
+
+ if (!(new_data = HeapReAlloc(GetProcessHeap(), 0, cs->data, new_size)))
return NULL;
- cs->data_size *= 2;
+ cs->data_size = new_size;
cs->data = new_data;
}
--
1.7.9.5
More information about the wine-patches
mailing list