shared: prevent dereferencing of NULL pointers

It is necessary to add checks for NULL before dereferencing pointers.

Found with the SVACE static analysis tool.
2 files changed