Skip to content

Commit efa1e89

Browse files
cosmo0920edsiper
authored andcommitted
utils: Remove a needless flb_free
out_size is just for used to return the lentgth of ID string. Removing this flb_free does not cause memory leaks. ``` % leaks -atExit -- bin/flb-it-utils test_flb_utils_get_machine_id flb-it-utils(34841) MallocStackLogging: could not tag MSL-related memory as no_footprint, so those pages will be included in process footprint - (null) flb-it-utils(34841) MallocStackLogging: recording malloc and VM allocation stacks using lite mode Test test_flb_utils_get_machine_id... [ OK ] SUCCESS: All unit tests have passed. Process 34841 is not debuggable. Due to security restrictions, leaks can only show or save contents of readonly memory of restricted processes. Process: flb-it-utils [34841] Path: /Users/USER/*/flb-it-utils Load Address: 0x1023cc000 Identifier: flb-it-utils Version: 0 Code Type: ARM64 Platform: macOS Parent Process: leaks [34840] Date/Time: 2024-03-06 23:42:29.641 +0900 Launch Time: 2024-03-06 23:42:29.596 +0900 OS Version: macOS 14.3.1 (23D60) Report Version: 7 Analysis Tool: /usr/bin/leaks Physical footprint: 4385K Physical footprint (peak): 4385K Idle exit: untracked ---- leaks Report Version: 4.0, multi-line stacks Process 34841: 516 nodes malloced for 42 KB Process 34841: 0 leaks for 0 total leaked bytes. ``` Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 431b287 commit efa1e89

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/flb_utils.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,6 @@ int flb_utils_get_machine_id(char **out_id, size_t *out_size)
14561456
CFRelease(serialNumber);
14571457

14581458
if (bret == false) {
1459-
flb_free(*out_size);
14601459
*out_size = 0;
14611460
return -1;
14621461
}

tests/internal/utils.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,19 @@ void test_flb_utils_split_quoted_errors()
605605
TEST_CHECK(split == NULL);
606606
}
607607

608+
void test_flb_utils_get_machine_id()
609+
{
610+
int ret;
611+
char *id = NULL;
612+
size_t size;
613+
614+
ret = flb_utils_get_machine_id(&id, &size);
615+
TEST_CHECK(size != 0);
616+
TEST_CHECK(id != NULL);
617+
618+
flb_free(id);
619+
}
620+
608621
TEST_LIST = {
609622
/* JSON maps iteration */
610623
{ "url_split", test_url_split },
@@ -618,5 +631,6 @@ TEST_LIST = {
618631
{ "test_flb_utils_split", test_flb_utils_split },
619632
{ "test_flb_utils_split_quoted", test_flb_utils_split_quoted},
620633
{ "test_flb_utils_split_quoted_errors", test_flb_utils_split_quoted_errors},
634+
{ "test_flb_utils_get_machine_id", test_flb_utils_get_machine_id },
621635
{ 0 }
622636
};

0 commit comments

Comments
 (0)