Mercurial > octave
diff libinterp/dldfcn/audiodevinfo.cc @ 26219:471513a016ec
Fix audiorecorder() crash in getaudiodata() (bug #50674)
audiodevinfo.cc (audiorecorder::getaudiodata): Determine buffersize *before*
starting loop. Otherwise, it may change while the loop is running causing
the index for right channel to go out of bounds.
author | Lars Kindermann |
---|---|
date | Wed, 26 Sep 2018 18:12:59 +0200 |
parents | 29387b9ccfbb |
children | 0249ba4c9589 00f796120a6d |
line wrap: on
line diff
--- a/libinterp/dldfcn/audiodevinfo.cc Wed Dec 12 21:19:46 2018 -0800 +++ b/libinterp/dldfcn/audiodevinfo.cc Wed Sep 26 18:12:59 2018 +0200 @@ -1639,9 +1639,12 @@ octave_value audiorecorder::getaudiodata (void) { - Matrix audio (2, left.size ()); - - for (unsigned int i = 0; i < left.size (); i++) + // Must get size before entering loop as the value of left.size() may change + // during loop with simultaneous recording and playback (bug #50674). + unsigned int ls = left.size (); + Matrix audio (2, ls); + + for (unsigned int i = 0; i < ls; i++) { audio(0,i) = left[i]; audio(1,i) = right[i];