From a15c2a5c61c587ded738d71c1bcf81470ea4babe Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 22 Oct 2018 16:08:49 -0700 Subject: [PATCH] test-tool/test_prin_read_keys_truncate: Do not crash if PERSISTENT RESERVE IN fails Do not try to dereference the 'rk' pointer if it is NULL. Signed-off-by: Bart Van Assche --- test-tool/test_prin_read_keys_truncate.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test-tool/test_prin_read_keys_truncate.c b/test-tool/test_prin_read_keys_truncate.c index 1590b33..976269c 100644 --- a/test-tool/test_prin_read_keys_truncate.c +++ b/test-tool/test_prin_read_keys_truncate.c @@ -58,15 +58,17 @@ test_prin_read_keys_truncate(void) } CU_ASSERT_EQUAL(ret, 0); - /* - * SPC5r17: 6.16.2 READ KEYS service action - * The ADDITIONAL LENGTH field indicates the number of bytes in - * the Reservation key list. The contents of the ADDITIONAL - * LENGTH field are not altered based on the allocation length. - */ - CU_ASSERT_NOT_EQUAL(rk->additional_length, 0); - /* key array should have been truncated in the response */ - CU_ASSERT_EQUAL(rk->num_keys, 0); + if (rk) { + /* + * SPC5r17: 6.16.2 READ KEYS service action + * The ADDITIONAL LENGTH field indicates the number of bytes in + * the Reservation key list. The contents of the ADDITIONAL + * LENGTH field are not altered based on the allocation length. + */ + CU_ASSERT_NOT_EQUAL(rk->additional_length, 0); + /* key array should have been truncated in the response */ + CU_ASSERT_EQUAL(rk->num_keys, 0); + } /* remove our key from the target */ ret = prout_register_key(sd, 0, key);