@@ -2793,7 +2793,6 @@ static void s_aws_mqtt_set_metrics_task_destroy(struct aws_mqtt_set_metrics_task
27932793 }
27942794
27952795 aws_mqtt_iot_sdk_metrics_storage_destroy (task -> metrics_storage );
2796-
27972796 aws_mem_release (task -> allocator , task );
27982797}
27992798
@@ -2806,19 +2805,15 @@ static void s_set_metrics_task_fn(struct aws_task *task, void *arg, enum aws_tas
28062805 goto done ;
28072806 }
28082807
2809- if (set_task -> metrics_storage && aws_mqtt_validate_iot_sdk_metrics (& set_task -> metrics_storage -> storage_view )) {
2810- AWS_LOGF_ERROR (AWS_LS_MQTT5_TO_MQTT3_ADAPTER , "invalid metrics in client configuration" );
2811- goto done ;
2812- }
2813-
28142808 /* we're in the mqtt5 client's event loop; it's safe to access internal state */
28152809 struct aws_mqtt5_client_options_storage * client_options = adapter -> client -> config ;
28162810 if (client_options -> metrics_storage ) {
28172811 aws_mqtt_iot_sdk_metrics_storage_destroy (client_options -> metrics_storage );
2812+ client_options -> metrics_storage = NULL ;
28182813 }
28192814
2820- client_options -> metrics_storage = aws_mqtt_iot_sdk_metrics_storage_new (
2821- set_task -> allocator , set_task -> metrics_storage ? & set_task -> metrics_storage -> storage_view : NULL ) ;
2815+ client_options -> metrics_storage = set_task -> metrics_storage ;
2816+ set_task -> metrics_storage = NULL ;
28222817
28232818done :
28242819 aws_ref_count_release (& adapter -> internal_refs );
@@ -2841,6 +2836,10 @@ static struct aws_mqtt_set_metrics_task *s_aws_mqtt_set_metrics_task_new(
28412836
28422837 if (metrics != NULL ) {
28432838 set_task -> metrics_storage = aws_mqtt_iot_sdk_metrics_storage_new (allocator , metrics );
2839+ if (!set_task -> metrics_storage ) {
2840+ s_aws_mqtt_set_metrics_task_destroy (set_task );
2841+ return NULL ;
2842+ }
28442843 }
28452844
28462845 return set_task ;
@@ -2850,9 +2849,8 @@ static int s_aws_mqtt_client_connection_5_set_metrics(void *impl, const struct a
28502849 struct aws_mqtt_client_connection_5_impl * adapter = impl ;
28512850
28522851 if (aws_mqtt_validate_iot_sdk_metrics (metrics )) {
2853- AWS_LOGF_DEBUG (
2854- AWS_LS_MQTT5_TO_MQTT3_ADAPTER , "id=%p: Invalid utf8 or forbidden codepoints in metrics." , (void * )adapter );
2855- return aws_raise_error (AWS_ERROR_INVALID_UTF8 );
2852+ AWS_LOGF_DEBUG (AWS_LS_MQTT5_TO_MQTT3_ADAPTER , "id=%p: Invalid metrics." , (void * )adapter );
2853+ return AWS_OP_ERR ;
28562854 }
28572855
28582856 struct aws_mqtt_set_metrics_task * task = s_aws_mqtt_set_metrics_task_new (adapter -> allocator , adapter , metrics );
0 commit comments