tool: fix memory leak
authorShinwoo Kim <cinoo.kim@samsung.com>
Mon, 27 Mar 2017 03:56:54 +0000 (12:56 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Tue, 28 Mar 2017 06:58:00 +0000 (15:58 +0900)
Change-Id: I90c8f22d555c36db6f66e2250e333bf32ea86d8e

test/at_spi2_tool.c

index badaaa3..2eae131 100644 (file)
@@ -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]");