Matlab S-Function: Why does ssGetInputPortSignal() return NULL?

There are several different reasons why ssGetInputPortSignal() returns NULL or nullptr?

real_T *input = ssGetInputPortSignal(S, 0);
if (!ssGetInputPortConnected(S, 0)) {
    mexPrintf("Input port 0 is not connected\n");
}