From b95659e66457646684e98ccbd878e2fb346b489c Mon Sep 17 00:00:00 2001 From: Shinwoo Kim Date: Mon, 27 Mar 2017 12:56:54 +0900 Subject: [PATCH] tool: fix memory leak Change-Id: I90c8f22d555c36db6f66e2250e333bf32ea86d8e --- test/at_spi2_tool.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/at_spi2_tool.c b/test/at_spi2_tool.c index badaaa3..2eae131 100644 --- a/test/at_spi2_tool.c +++ b/test/at_spi2_tool.c @@ -326,6 +326,9 @@ static char *_get_info(AtspiAccessible *node, int length_limit) Box_Size *box_size = _get_box_size(node); char *states = _get_states(node, length_limit); + char *flows_to = _get_object_in_relation(node, ATSPI_RELATION_FLOWS_TO); + char *flows_from = _get_object_in_relation(node, ATSPI_RELATION_FLOWS_FROM); + char result[SAFE_BUFFER_SIZE]; int ret = snprintf(result, SAFE_BUFFER_SIZE, "[[%s],[%s],[%s],[%s,%s,%s,%s],[%s],[%s],[%s,%s]]", path, @@ -337,14 +340,15 @@ static char *_get_info(AtspiAccessible *node, int length_limit) box_size->height, node_name, states, - _get_object_in_relation(node, ATSPI_RELATION_FLOWS_TO), - _get_object_in_relation(node, ATSPI_RELATION_FLOWS_FROM)); + flows_to, + flows_from); if (ret >= SAFE_BUFFER_SIZE) fprintf(stderr, "\n%s, %s %s: generated string is too long. Buffer overflow\n", __FILE__, __FUNCTION__, __LINE__); free(node_name); free(node_role_name); + free(path); free(attributes); if (box_size) { free(box_size->width); @@ -352,6 +356,8 @@ static char *_get_info(AtspiAccessible *node, int length_limit) free(box_size); } free(states); + free(flows_to); + free(flows_from); return _strdup(result); } @@ -370,9 +376,12 @@ static void _test_atspi_parent_child_relation(AtspiAccessible *obj, AtspiAccessi else snprintf(parent_status, NUMBER_WIDTH, "%d", parent_index); + char *parent_path = atspi_accessible_get_path(parent, NULL); + char *parent_candidate_path = atspi_accessible_get_path(parent_candidate, NULL); snprintf(output, CHECK_OUTPUT_WIDTH, "[FAIL<%d,%s><%s,%s>]", parent_candidate_index, parent_status, - atspi_accessible_get_path(parent_candidate, NULL), - atspi_accessible_get_path(parent, NULL)); + parent_candidate_path, parent_path); + free(parent_path); + free(parent_candidate_path); } else { snprintf(output, CHECK_OUTPUT_WIDTH, "[OK]"); -- 2.7.4