Skip to content

Commit 2ac9e3c

Browse files
committed
aws_credentials_sts: internal: Use early return when allocation is failed
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 012f6e1 commit 2ac9e3c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/internal/aws_credentials_sts.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ struct flb_http_client *request_eks_test1(struct flb_aws_client *aws_client,
212212
mk_list_init(&c->headers);
213213
payload = build_eks_response_with_ttl_calloc(3600, &payload_len);
214214
TEST_CHECK(payload != NULL);
215+
if (!payload) {
216+
return NULL;
217+
}
215218

216219
http_test_attach_owned_payload(c, payload, payload_len);
217220

@@ -246,6 +249,9 @@ struct flb_http_client *request_eks_flb_sts_session_name(struct flb_aws_client
246249
mk_list_init(&c->headers);
247250
payload = build_eks_response_with_ttl_calloc(3600, &payload_len);
248251
TEST_CHECK(payload != NULL);
252+
if (!payload) {
253+
return NULL;
254+
}
249255

250256
http_test_attach_owned_payload(c, payload, payload_len);
251257

@@ -305,6 +311,9 @@ struct flb_http_client *request_sts_test1(struct flb_aws_client *aws_client,
305311
mk_list_init(&c->headers);
306312
payload = build_sts_response_with_ttl_calloc(3600, &payload_len);
307313
TEST_CHECK(payload != NULL);
314+
if (!payload) {
315+
return NULL;
316+
}
308317

309318
http_test_attach_owned_payload(c, payload, payload_len);
310319

@@ -469,6 +478,9 @@ static void test_process_sts_response()
469478
}
470479
payload = build_eks_response_with_ttl_calloc(3600, &payload_len);
471480
TEST_CHECK(payload != NULL);
481+
if (!payload) {
482+
return;
483+
}
472484

473485
creds = flb_parse_sts_resp(payload, &expiration);
474486

0 commit comments

Comments
 (0)