dmusic: do not write outside of array bounds

Peter Oberndorfer kumbayo84 at arcor.de
Fri Oct 27 11:47:25 CDT 2006


helps Gothic II to get a bit futher with wine dmusic
writing outside of array bounds would corrupt heap structures and make later heap allocations fail
found by turning on heap trace, which poisons uninitialized data

Changelog:
dmusic: do not write outside of array bounds
-------------- next part --------------
From 35d5edced7bd0ee5d7cfc32063f41e62d584c809 Mon Sep 17 00:00:00 2001
From: Peter Oberndorfer <kumbayo84 at arcor.de>
Date: Fri, 27 Oct 2006 18:10:37 +0200
Subject: [PATCH] dmusic: do not write outside of array bounds
---
 dlls/dmusic/dmusic.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dlls/dmusic/dmusic.c b/dlls/dmusic/dmusic.c
index daa489b..675430a 100644
--- a/dlls/dmusic/dmusic.c
+++ b/dlls/dmusic/dmusic.c
@@ -133,7 +133,7 @@ static HRESULT WINAPI IDirectMusic8Impl_
 			This->nrofports++;
 			if (!This->ppPorts) This->ppPorts = HeapAlloc(GetProcessHeap(), 0, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
 			else This->ppPorts = HeapReAlloc(GetProcessHeap(), 0, This->ppPorts, sizeof(LPDIRECTMUSICPORT) * This->nrofports); 			
-			This->ppPorts[This->nrofports] = pNewPort;
+			This->ppPorts[This->nrofports - 1] = pNewPort;
 			*ppPort = (LPDIRECTMUSICPORT) pNewPort;
 			return S_OK;			
 		}
-- 
1.4.3.2



More information about the wine-patches mailing list