diff mbox series

[7/9] ossaudio: prevent SIGPFE in oss_write

Message ID 20200123074943.6699-7-vr_qemu@t-online.de
State New
Headers show
Series more audio fixes and improvements | expand

Commit Message

Volker RĂ¼melin Jan. 23, 2020, 7:49 a.m. UTC
The new buffer write position is modulo the buffer size.

To reproduce start qemu with:
-audiodev oss,id=audio0,try-mmap=on,out.mixing-engine=off

Signed-off-by: Volker RĂ¼melin <vr_qemu@t-online.de>
---
 audio/ossaudio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 6a3b78b381..39a6fc09e5 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -429,7 +429,7 @@  static size_t oss_write(HWVoiceOut *hw, void *buf, size_t len)
             size_t to_copy = MIN(len, hw->size_emul - hw->pos_emul);
             memcpy(hw->buf_emul + hw->pos_emul, buf, to_copy);
 
-            hw->pos_emul = (hw->pos_emul + to_copy) % hw->pos_emul;
+            hw->pos_emul = (hw->pos_emul + to_copy) % hw->size_emul;
             buf += to_copy;
             len -= to_copy;
         }