diff options
author | michi_cc <michi_cc@openttd.org> | 2011-09-02 20:16:41 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2011-09-02 20:16:41 +0000 |
commit | 65637d89411e96dee5ee9fc2e8a7b3805c4162a2 (patch) | |
tree | 79fdfb3cefba4457d3b81760173c5ca68e359a81 /src/sound | |
parent | 6c7cbb1d46d266d33e49bd42a52e483296313882 (diff) | |
download | openttd-65637d89411e96dee5ee9fc2e8a7b3805c4162a2.tar.xz |
(svn r22874) -Fix [FS#4747]: Check size of various buffers before allocation. (monoid)
Diffstat (limited to 'src/sound')
-rw-r--r-- | src/sound/win32_s.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/sound/win32_s.cpp b/src/sound/win32_s.cpp index c0e5da5d2..ef3f98f40 100644 --- a/src/sound/win32_s.cpp +++ b/src/sound/win32_s.cpp @@ -63,7 +63,9 @@ const char *SoundDriver_Win32::Start(const char * const *parm) wfex.nBlockAlign = (wfex.nChannels * wfex.wBitsPerSample) / 8; wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign; + /* Limit buffer size to prevent overflows. */ _bufsize = GetDriverParamInt(parm, "bufsize", (GB(GetVersion(), 0, 8) > 5) ? 8192 : 4096); + _bufsize = min(_bufsize, UINT16_MAX); try { if (NULL == (_event = CreateEvent(NULL, FALSE, FALSE, NULL))) throw "Failed to create event"; |