TS-1475: Fixing issue that might dereference a NULL pointer. Coverity #1021649