       IrSendTable[i] = NULL;
     } else {
       IrSendTable[i] = new IRsend(txGpioTable[i]);
+      if (IrSendTable[i] == NULL) break;
       IrSendTable[i]->begin();
       offset = IrSendTable[i]->calibrate();
     }

  climate.clock = -1;  // Don't set.
  climate_prev = climate;
  lastClimateSource = F("None");
  // Ensure the rest of txGpioTable is initialised to unused.
  for (uint16_t i = 1; i < kNrOfIrTxGpios ; i++)
    txGpioTable[i] = kGpioUnused;

#if DEBUG
  if (!isSerialGpioUsedByIr()) {

  // constructing the PUBLISH packet.
  // Allocate the correct amount of memory for the payload copy
  byte* payload_copy = reinterpret_cast<byte*>(malloc(length + 1));
  if (payload_copy == NULL) {
    debug("Can't allocate memory for `payload_copy`. Skipping callback!");
    return;
  }
  // Copy the payload to the new buffer
  memcpy(payload_copy, payload, length);

