main: Check if object is valid before accessing it
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>