More defensive programming.

Signed-off-by: Thiago Farina <tfarina@chromium.org>