diff --git a/src/flb_utils.c b/src/flb_utils.c index b227af376c1..87637f1331d 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -1456,7 +1456,6 @@ int flb_utils_get_machine_id(char **out_id, size_t *out_size) CFRelease(serialNumber); if (bret == false) { - flb_free(*out_size); *out_size = 0; return -1; } diff --git a/tests/internal/utils.c b/tests/internal/utils.c index 119094bdeb7..beec9099ecc 100644 --- a/tests/internal/utils.c +++ b/tests/internal/utils.c @@ -605,6 +605,19 @@ void test_flb_utils_split_quoted_errors() TEST_CHECK(split == NULL); } +void test_flb_utils_get_machine_id() +{ + int ret; + char *id = NULL; + size_t size; + + ret = flb_utils_get_machine_id(&id, &size); + TEST_CHECK(size != 0); + TEST_CHECK(id != NULL); + + flb_free(id); +} + TEST_LIST = { /* JSON maps iteration */ { "url_split", test_url_split }, @@ -618,5 +631,6 @@ TEST_LIST = { { "test_flb_utils_split", test_flb_utils_split }, { "test_flb_utils_split_quoted", test_flb_utils_split_quoted}, { "test_flb_utils_split_quoted_errors", test_flb_utils_split_quoted_errors}, + { "test_flb_utils_get_machine_id", test_flb_utils_get_machine_id }, { 0 } };