Skip to content

Commit

Permalink
Prevent crash if passed a NULL pointer for inputQueue
Browse files Browse the repository at this point in the history
Could occur if the queue pointers block is dynamically allocated, e.g. for the variable-width mixer object.
  • Loading branch information
h4yn0nnym0u5e committed Jan 5, 2022
1 parent 180c7b0 commit fcfc66a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions teensy4/AudioStream.h
Expand Up @@ -193,8 +193,13 @@ class AudioStream
next_clan = first_clan; // ...are in a new clan...
first_clan = this;
next_update = NULL; // ...with only us in it
for (int i=0; i < num_inputs; i++) {
inputQueue[i] = NULL;

if (NULL == inputQueue) // could be a failed malloc()
num_inputs = 0; // prevent use of queues
else
{
for (int i=0; i < num_inputs; i++)
inputQueue[i] = NULL;
}
// add to a simple list, for update_all
// TODO: replace with a proper data flow analysis in update_all
Expand Down

0 comments on commit fcfc66a

Please sign in to comment.