vboot/ui: Check allocated pointer before using the pointer

Change the order of checking whether the allocated pointer is null
and memset the allocated pointer. Prevent using a null pointer, which
may cause segmentation fault.

TEST=export CC=x86_64-pc-linux-gnu-clang DEBUG=1 \
     make -j32 test_setup && make -j32 runtests;
TEST=emerge-asurada depthcharge

Signed-off-by: edisonhello <edisonhello@google.com>
Change-Id: I5fc91b5157b32b6b7263d580998eceb6efe9a63a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3077962
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
1 file changed