Possible nullptr


Looking at the code on github I found something which looks suspisious to me.

static void keyChosen (int result, ChangeKeyButton* button)
    if (result != 0 && button != nullptr && button->currentKeyEntryWindow != nullptr)
        button->currentKeyEntryWindow->setVisible (false);
        button->setNewKey (button->currentKeyEntryWindow->lastPress, false);  
    button->currentKeyEntryWindow = nullptr;


Here you have `if` which checkes button for nullptr, but then it is simply dereferencing it without check.


For me it should be:

  • put `button->currentKeyEntryWindow` inside `if` statement


  • remove `buttonn != nullptr` as it will fail in the next statement

Preferably the first one, but maybe I am missing something :)


And at the end, as this is my first post (who knows, maybe not last wink)

Great job on this library. I found JUCE few years ago and after that time, when I am now looking at it again I am still amazed of quality of code and care it is written with. I listened cppcast with Jules today, and as he said: every whitespace matters. 


chapeau bas

Thanks! That does look like a mistake, I'll take a look...