@@ -154,6 +154,7 @@ int callback(const void* input, void* output, frame_t frameCount
154154
155155 // Get number of remaining frames in the current block
156156
157+ CALLBACK_ASSERT (action -> total_frames >= action -> done_frames );
157158 frame_t frames = action -> total_frames - action -> done_frames ;
158159
159160 if (frameCount < frames )
@@ -182,6 +183,8 @@ int callback(const void* input, void* output, frame_t frameCount
182183 {
183184 for (frame_t c = 0 ; c < action -> channels ; c ++ )
184185 {
186+ CALLBACK_ASSERT (action -> mapping [c ] >= 1 );
187+ CALLBACK_ASSERT (action -> mapping [c ] <= state -> output_channels );
185188 device_data [action -> mapping [c ] - 1 ] += * buffer ++ ;
186189 }
187190 device_data += state -> output_channels ;
@@ -195,6 +198,8 @@ int callback(const void* input, void* output, frame_t frameCount
195198 {
196199 for (frame_t c = 0 ; c < action -> channels ; c ++ )
197200 {
201+ CALLBACK_ASSERT (action -> mapping [c ] >= 1 );
202+ CALLBACK_ASSERT (action -> mapping [c ] <= state -> input_channels );
198203 * buffer ++ = device_data [action -> mapping [c ] - 1 ];
199204 }
200205 device_data += state -> input_channels ;
@@ -217,11 +222,14 @@ int callback(const void* input, void* output, frame_t frameCount
217222 totalsize = PaUtil_GetRingBufferReadRegions (action -> ringbuffer
218223 , (ring_buffer_size_t )frames
219224 , (void * * )& block1 , & size1 , (void * * )& block2 , & size2 );
225+ CALLBACK_ASSERT (!totalsize || size1 );
220226
221227 while (size1 -- )
222228 {
223229 for (frame_t c = 0 ; c < action -> channels ; c ++ )
224230 {
231+ CALLBACK_ASSERT (action -> mapping [c ] >= 1 );
232+ CALLBACK_ASSERT (action -> mapping [c ] <= state -> output_channels );
225233 device_data [action -> mapping [c ] - 1 ] += * block1 ++ ;
226234 }
227235 device_data += state -> output_channels ;
@@ -244,12 +252,15 @@ int callback(const void* input, void* output, frame_t frameCount
244252 totalsize = PaUtil_GetRingBufferWriteRegions (action -> ringbuffer
245253 , (ring_buffer_size_t )frames
246254 , (void * * )& block1 , & size1 , (void * * )& block2 , & size2 );
255+ CALLBACK_ASSERT (!totalsize || size1 );
247256
248257 while (size1 -- )
249258 {
250259 for (frame_t c = 0 ; c < action -> channels ; c ++ )
251260 {
252- * block1 ++ = device_data [action -> mapping [c ] - 1 ];
261+ CALLBACK_ASSERT (action -> mapping [c ] >= 1 );
262+ CALLBACK_ASSERT (action -> mapping [c ] <= state -> input_channels );
263+ * block1 ++ = device_data [action -> mapping [c ] - 1 ];
253264 }
254265 device_data += state -> input_channels ;
255266 }
0 commit comments