diff --git a/source/request-response/request_response_client.c b/source/request-response/request_response_client.c index 7b43f452..a692e813 100644 --- a/source/request-response/request_response_client.c +++ b/source/request-response/request_response_client.c @@ -218,6 +218,9 @@ static struct aws_mqtt_request_response_client *s_aws_mqtt_request_response_clie * initialize can't fail by checking its options for validity now. */ if (!aws_rr_subscription_manager_are_options_valid(&sm_options)) { + AWS_LOGF_ERROR( + AWS_LS_MQTT_REQUEST_RESPONSE, "(static) request response client creation failed - invalid client options"); + aws_raise_error(AWS_ERROR_INVALID_ARGUMENT); return NULL; } @@ -311,6 +314,10 @@ struct aws_mqtt_request_response_client *aws_mqtt_request_response_client_new_fr struct aws_mqtt_request_response_client *rr_client = s_aws_mqtt_request_response_client_new(allocator, options, aws_mqtt_client_connection_get_event_loop(client)); + if (rr_client == NULL) { + return NULL; + } + struct aws_mqtt_protocol_adapter_options adapter_options = { .subscription_event_callback = s_aws_rr_client_protocol_adapter_subscription_event_callback, .incoming_publish_callback = s_aws_rr_client_protocol_adapter_incoming_publish_callback, @@ -344,6 +351,10 @@ struct aws_mqtt_request_response_client *aws_mqtt_request_response_client_new_fr struct aws_mqtt_request_response_client *rr_client = s_aws_mqtt_request_response_client_new(allocator, options, client->loop); + if (rr_client == NULL) { + return NULL; + } + struct aws_mqtt_protocol_adapter_options adapter_options = { .subscription_event_callback = s_aws_rr_client_protocol_adapter_subscription_event_callback, .incoming_publish_callback = s_aws_rr_client_protocol_adapter_incoming_publish_callback, diff --git a/tests/request-response/request_response_client_tests.c b/tests/request-response/request_response_client_tests.c index 633ee42b..226efdf0 100644 --- a/tests/request-response/request_response_client_tests.c +++ b/tests/request-response/request_response_client_tests.c @@ -19,7 +19,7 @@ enum rr_test_client_protocol { struct aws_rr_client_test_fixture { struct aws_allocator *allocator; - struct aws_mqtt_request_response_client *client; + struct aws_mqtt_request_response_client *rr_client; enum rr_test_client_protocol test_protocol; union { @@ -98,9 +98,9 @@ static int s_aws_rr_client_test_fixture_init_from_mqtt5( client_options.terminated_callback = s_aws_rr_client_test_fixture_on_terminated; client_options.user_data = fixture; - fixture->client = aws_mqtt_request_response_client_new_from_mqtt5_client( + fixture->rr_client = aws_mqtt_request_response_client_new_from_mqtt5_client( allocator, fixture->client_test_fixture.mqtt5_test_fixture.client, &client_options); - AWS_FATAL_ASSERT(fixture->client != NULL); + AWS_FATAL_ASSERT(fixture->rr_client != NULL); aws_mqtt5_client_start(fixture->client_test_fixture.mqtt5_test_fixture.client); @@ -140,8 +140,9 @@ static int s_aws_rr_client_test_fixture_init_from_mqtt311( struct aws_mqtt_client_connection *mqtt_client = fixture->client_test_fixture.mqtt311_test_fixture.mqtt_connection; - fixture->client = aws_mqtt_request_response_client_new_from_mqtt311_client(allocator, mqtt_client, &client_options); - AWS_FATAL_ASSERT(fixture->client != NULL); + fixture->rr_client = + aws_mqtt_request_response_client_new_from_mqtt311_client(allocator, mqtt_client, &client_options); + AWS_FATAL_ASSERT(fixture->rr_client != NULL); struct aws_mqtt_connection_options connection_options = { .user_data = &fixture->client_test_fixture.mqtt311_test_fixture, @@ -169,7 +170,7 @@ static bool s_rr_client_test_fixture_terminated(void *context) { } static void s_aws_rr_client_test_fixture_clean_up(struct aws_rr_client_test_fixture *fixture) { - aws_mqtt_request_response_client_release(fixture->client); + aws_mqtt_request_response_client_release(fixture->rr_client); aws_mutex_lock(&fixture->lock); aws_condition_variable_wait_pred(&fixture->signal, &fixture->lock, s_rr_client_test_fixture_terminated, fixture);