Module: wine Branch: master Commit: 86e88f51b88f99514d1a00f9ee60c0a60232c7b1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=86e88f51b88f99514d1a00f9ee...
Author: Stefan Dösinger stefan@codeweavers.com Date: Fri Jan 3 14:17:18 2014 +0100
d3dx9_36: Improve error handling in remap_faces_for_attrsort.
---
dlls/d3dx9_36/mesh.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c index 133f14d..b713079 100644 --- a/dlls/d3dx9_36/mesh.c +++ b/dlls/d3dx9_36/mesh.c @@ -1615,12 +1615,17 @@ static HRESULT remap_faces_for_attrsort(struct d3dx9_mesh *This, const DWORD *in DWORD **sorted_attrib_ptr_buffer = NULL; DWORD i;
- *face_remap = HeapAlloc(GetProcessHeap(), 0, This->numfaces * sizeof(**face_remap)); sorted_attrib_ptr_buffer = HeapAlloc(GetProcessHeap(), 0, This->numfaces * sizeof(*sorted_attrib_ptr_buffer)); - if (!*face_remap || !sorted_attrib_ptr_buffer) { + if (!sorted_attrib_ptr_buffer) + return E_OUTOFMEMORY; + + *face_remap = HeapAlloc(GetProcessHeap(), 0, This->numfaces * sizeof(**face_remap)); + if (!*face_remap) + { HeapFree(GetProcessHeap(), 0, sorted_attrib_ptr_buffer); return E_OUTOFMEMORY; } + for (i = 0; i < This->numfaces; i++) sorted_attrib_ptr_buffer[i] = &attrib_buffer[i]; qsort(sorted_attrib_ptr_buffer, This->numfaces, sizeof(*sorted_attrib_ptr_buffer),