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

Alexandre Julliard julliard at winehq.org
Thu Feb 14 15:01:31 CST 2013


Module: wine
Branch: master
Commit: f12855143939e28d9912991674a58129dfb8f884
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f12855143939e28d9912991674a58129dfb8f884

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Wed Feb 13 23:44:39 2013 +0100

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

---

 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");




More information about the wine-cvs mailing list