Check for NULL pointer before dereferencing keyval