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 <bvanassche@acm.org>
This commit is contained in:
Bart Van Assche
2018-10-22 16:08:49 -07:00
parent ac9a8e5aed
commit a15c2a5c61

View File

@@ -58,6 +58,7 @@ test_prin_read_keys_truncate(void)
} }
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (rk) {
/* /*
* SPC5r17: 6.16.2 READ KEYS service action * SPC5r17: 6.16.2 READ KEYS service action
* The ADDITIONAL LENGTH field indicates the number of bytes in * The ADDITIONAL LENGTH field indicates the number of bytes in
@@ -67,6 +68,7 @@ test_prin_read_keys_truncate(void)
CU_ASSERT_NOT_EQUAL(rk->additional_length, 0); CU_ASSERT_NOT_EQUAL(rk->additional_length, 0);
/* key array should have been truncated in the response */ /* key array should have been truncated in the response */
CU_ASSERT_EQUAL(rk->num_keys, 0); CU_ASSERT_EQUAL(rk->num_keys, 0);
}
/* remove our key from the target */ /* remove our key from the target */
ret = prout_register_key(sd, 0, key); ret = prout_register_key(sd, 0, key);