From f0613a37865ac578ac75df9153ef1eac91ed424e Mon Sep 17 00:00:00 2001 From: Grzegorz Kolodziejczyk Date: Wed, 17 Dec 2014 15:01:34 +0100 Subject: [PATCH] android/tester: Add verification for test case list creators To be safe it must be chcecked if queue_new and add test case to list was successful. --- android/tester-a2dp.c | 6 +++++- android/tester-avrcp.c | 6 +++++- android/tester-bluetooth.c | 6 +++++- android/tester-gatt.c | 6 +++++- android/tester-hdp.c | 6 +++++- android/tester-hidhost.c | 6 +++++- android/tester-pan.c | 6 +++++- android/tester-socket.c | 6 +++++- 8 files changed, 40 insertions(+), 8 deletions(-) diff --git a/android/tester-a2dp.c b/android/tester-a2dp.c index eb882443f..f7d82c957 100644 --- a/android/tester-a2dp.c +++ b/android/tester-a2dp.c @@ -236,10 +236,14 @@ struct queue *get_a2dp_tests(void) uint16_t i = 0; list = queue_new(); + if (!list) + return NULL; for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i) - if (!queue_push_tail(list, &test_cases[i])) + if (!queue_push_tail(list, &test_cases[i])) { + queue_destroy(list, NULL); return NULL; + } return list; } diff --git a/android/tester-avrcp.c b/android/tester-avrcp.c index 24953a277..cec978786 100644 --- a/android/tester-avrcp.c +++ b/android/tester-avrcp.c @@ -584,10 +584,14 @@ struct queue *get_avrcp_tests(void) uint16_t i = 0; list = queue_new(); + if (!list) + return NULL; for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i) - if (!queue_push_tail(list, &test_cases[i])) + if (!queue_push_tail(list, &test_cases[i])) { + queue_destroy(list, NULL); return NULL; + } return list; } diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c index c61b87c73..1381f6311 100644 --- a/android/tester-bluetooth.c +++ b/android/tester-bluetooth.c @@ -1224,10 +1224,14 @@ struct queue *get_bluetooth_tests(void) uint16_t i = 0; list = queue_new(); + if (!list) + return NULL; for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i) - if (!queue_push_tail(list, &test_cases[i])) + if (!queue_push_tail(list, &test_cases[i])) { + queue_destroy(list, NULL); return NULL; + } return list; } diff --git a/android/tester-gatt.c b/android/tester-gatt.c index 9ba204978..f6b04924e 100644 --- a/android/tester-gatt.c +++ b/android/tester-gatt.c @@ -3394,10 +3394,14 @@ struct queue *get_gatt_tests(void) uint16_t i = 0; list = queue_new(); + if (!list) + return NULL; for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i) - if (!queue_push_tail(list, &test_cases[i])) + if (!queue_push_tail(list, &test_cases[i])) { + queue_destroy(list, NULL); return NULL; + } return list; } diff --git a/android/tester-hdp.c b/android/tester-hdp.c index 7397de4df..80f3b5f20 100644 --- a/android/tester-hdp.c +++ b/android/tester-hdp.c @@ -549,10 +549,14 @@ struct queue *get_hdp_tests(void) uint16_t i = 0; list = queue_new(); + if (!list) + return NULL; for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i) - if (!queue_push_tail(list, &test_cases[i])) + if (!queue_push_tail(list, &test_cases[i])) { + queue_destroy(list, NULL); return NULL; + } return list; } diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c index b3880b32a..ab5f12bbc 100644 --- a/android/tester-hidhost.c +++ b/android/tester-hidhost.c @@ -719,10 +719,14 @@ struct queue *get_hidhost_tests(void) uint16_t i = 0; list = queue_new(); + if (!list) + return NULL; for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i) - if (!queue_push_tail(list, &test_cases[i])) + if (!queue_push_tail(list, &test_cases[i])) { + queue_destroy(list, NULL); return NULL; + } return list; } diff --git a/android/tester-pan.c b/android/tester-pan.c index 4feb6cfa2..e033e215d 100644 --- a/android/tester-pan.c +++ b/android/tester-pan.c @@ -226,10 +226,14 @@ struct queue *get_pan_tests(void) uint16_t i = 0; list = queue_new(); + if (!list) + return NULL; for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i) - if (!queue_push_tail(list, &test_cases[i])) + if (!queue_push_tail(list, &test_cases[i])) { + queue_destroy(list, NULL); return NULL; + } return list; } diff --git a/android/tester-socket.c b/android/tester-socket.c index 3b1dd543a..41e143454 100644 --- a/android/tester-socket.c +++ b/android/tester-socket.c @@ -447,10 +447,14 @@ struct queue *get_socket_tests(void) uint16_t i = 0; list = queue_new(); + if (!list) + return NULL; for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i) - if (!queue_push_tail(list, &test_cases[i])) + if (!queue_push_tail(list, &test_cases[i])) { + queue_destroy(list, NULL); return NULL; + } return list; } -- 2.47.3