samples: net: nats: Check null before dereferrencing the variable
samples: net: nats: Check null before dereferrencing the variable

This patch checks null before deferencing the variable.

Fix Bug: #14815
Coverity CID: 196641

Signed-off-by: Tedd Ho-Jeong An <bccd9a0c49e2239629ed999837613a8438457215@intel.com>

ldts/zephyr,Vudentz/zephyr,galak/zephyr,finikorg/zephyr,Vudentz/zephyr,GiulianoFranchetto/zephyr,ldts/zephyr,nashif/zephyr,zephyrproject-rtos/zephyr,nashif/zephyr,zephyrproject-rtos/zephyr,galak/zephyr,galak/zephyr,GiulianoFranchetto/zephyr,nashif/zephyr,nashif/zephyr,GiulianoFranchetto/zephyr,nashif/zephyr,finikorg/zephyr,galak/zephyr,zephyrproject-rtos/zephyr,zephyrproject-rtos/zephyr,Vudentz/zephyr,GiulianoFranchetto/zephyr,Vudentz/zephyr,finikorg/zephyr,ldts/zephyr,GiulianoFranchetto/zephyr,finikorg/zephyr,ldts/zephyr,Vudentz/zephyr,ldts/zephyr,galak/zephyr,finikorg/zephyr,zephyrproject-rtos/zephyr,Vudentz/zephyr