Make sure state is valid before dereferencing it
Signed-off-by: Poornima Gupte <poornima.gupte@in.ibm.com>