From dd41980f1784c91dd8b30a9074a260621d366c2e Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Sun, 15 Jan 2023 14:50:25 +1100 Subject: tests/: Assert on NULL heap allocations in tests Change-Id: Id2adcfe859fb25d2a7f0734655c6b9a58c0890b6 Signed-off-by: Edward O'Callaghan Reviewed-on: https://review.coreboot.org/c/flashrom/+/71919 Tested-by: build bot (Jenkins) Reviewed-by: Anastasia Klimchuk --- tests/raiden_debug_spi.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/raiden_debug_spi.c') diff --git a/tests/raiden_debug_spi.c b/tests/raiden_debug_spi.c index f5bf185a..5c79a909 100644 --- a/tests/raiden_debug_spi.c +++ b/tests/raiden_debug_spi.c @@ -19,6 +19,7 @@ static ssize_t raiden_debug_libusb_get_device_list(void *state, libusb_context *ctx, libusb_device ***list) { *list = calloc(1, sizeof(**list)); + assert_non_null(*list); /* * libusb_device is opaque type, it is tossed around between libusb functions but always @@ -48,10 +49,14 @@ static int raiden_debug_libusb_get_config_descriptor( void *state, libusb_device *dev, uint8_t config_index, struct libusb_config_descriptor **config) { *config = calloc(1, sizeof(**config)); + assert_non_null(*config); struct libusb_endpoint_descriptor *tmp_endpoint = calloc(2, sizeof(*tmp_endpoint)); + assert_non_null(tmp_endpoint); struct libusb_interface_descriptor *tmp_interface_desc = calloc(1, sizeof(*tmp_interface_desc)); + assert_non_null(tmp_interface_desc); struct libusb_interface *tmp_interface = calloc(1, sizeof(*tmp_interface)); + assert_non_null(tmp_interface); /* in endpoint */ tmp_endpoint[0].bEndpointAddress = 0x80; -- cgit v1.2.3