diff options
author | Andrew Krasavin <[email protected]> | 2021-09-02 05:58:12 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-09-01 19:58:12 -0700 |
commit | a4b0a3d7b3ec271243cfda4780e567e49f2b37b7 (patch) | |
tree | b50df744e9f1a67ed01de8a8b4fa955d054d2671 /alc/backends/sndio.cpp | |
parent | 602b33fede0ce7d158ca96cda6db45742b2b2fce (diff) |
Fix crashes in SndioCapture::recordProc (#594)
* Fix crashes while capturing audio using openal with sndio backend.
* Proper function for mFds preallocation.
Now it is checked whether the returned value of the sin_nfds() function is not a negative number.
Diffstat (limited to 'alc/backends/sndio.cpp')
-rw-r--r-- | alc/backends/sndio.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp index 6852e01a..2c3eb3c7 100644 --- a/alc/backends/sndio.cpp +++ b/alc/backends/sndio.cpp @@ -311,6 +311,15 @@ int SndioCapture::recordProc() const uint frameSize{mDevice->frameSizeFromFmt()}; + int nfds_pre{sio_nfds(mSndHandle)}; + if (nfds_pre <= 0) + { + mDevice->handleDisconnect("Incorrect return value from sio_nfds(): %d", nfds_pre); + return 1; + } + + mFds.resize(nfds_pre); + while(!mKillNow.load(std::memory_order_acquire) && mDevice->Connected.load(std::memory_order_acquire)) { |