# HG changeset patch # User Lars Kindermann # Date 1537978379 -7200 # Node ID 471513a016ec2577ac8355817d260834e56580a1 # Parent 29387b9ccfbbcf93b38543166cfc13b04011176a 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. diff -r 29387b9ccfbb -r 471513a016ec libinterp/dldfcn/audiodevinfo.cc --- 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];