wineoss.drv: Use offsetof to calculate the size of a struct with variable length array

Michael Stefaniuc mstefani at redhat.de
Wed Feb 13 16:44:39 CST 2013


---
 dlls/wineoss.drv/midi.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/dlls/wineoss.drv/midi.c b/dlls/wineoss.drv/midi.c
index 0bf5d87..11b7c91 100644
--- a/dlls/wineoss.drv/midi.c
+++ b/dlls/wineoss.drv/midi.c
@@ -1115,8 +1115,7 @@ static DWORD modOpen(WORD wDevID, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
 	    void*	extra;
 
             extra = HeapAlloc(GetProcessHeap(), 0,
-                              sizeof(struct sFMextra) +
-                              sizeof(struct sVoice) * (MidiOutDev[wDevID].caps.wVoices - 1));
+                              offsetof(struct sFMextra, voice[MidiOutDev[wDevID].caps.wVoices]));
 
 	    if (extra == 0) {
 		WARN("can't alloc extra data !\n");
-- 
1.7.6.5



More information about the wine-patches mailing list