Commit 6e2b1b13 authored by Kevin Babbitt's avatar Kevin Babbitt Committed by Commit Bot

Address leaks in Linux accessibility tree tests

1. Unref AtkStateSet and AtkRelationSet when we're finished with them.

2. For atk_table_get_column_description and _row_description, we're
dynamically generating a value but the API appears to expect us to
return a static string. For now I've scoped the existing LSAN disabling
down to include just this spot since all remaining leaks are fixed.

Bug: 568674
Change-Id: I7174312452ae118eacb706cd7e686bf8649a790f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1688317
Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: default avatarMartin Robinson <mrobinson@igalia.com>
Cr-Commit-Position: refs/heads/master@{#676103}
parent 12c5376a
......@@ -276,6 +276,7 @@ void AccessibilityEventRecorderAuraLinux::ProcessATKEvent(
states = base::CollapseWhitespaceASCII(states, false);
base::ReplaceChars(states, " ", ",", &states);
log += base::StringPrintf(" %s", states.c_str());
g_object_unref(state_set);
OnEvent(log);
}
......
......@@ -509,6 +509,7 @@ void AccessibilityTreeFormatterAuraLinux::AddProperties(
states->AppendString(atk_state_type_get_name(state_type));
}
dict->Set("states", std::move(states));
g_object_unref(state_set);
AtkRelationSet* relation_set = atk_object_ref_relation_set(atk_object);
auto relations = std::make_unique<base::ListValue>();
......@@ -518,6 +519,7 @@ void AccessibilityTreeFormatterAuraLinux::AddProperties(
relations->AppendString(atk_relation_type_get_name(relation_type));
}
dict->Set("relations", std::move(relations));
g_object_unref(relation_set);
AtkAttributeSet* attributes = atk_object_get_attributes(atk_object);
for (AtkAttributeSet* attr = attributes; attr; attr = attr->next) {
......
......@@ -8,10 +8,8 @@
#include <string>
#include <vector>
#include "base/debug/leak_annotations.h"
#include "base/strings/string16.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "content/browser/accessibility/accessibility_event_recorder.h"
#include "content/public/browser/accessibility_tree_formatter.h"
#include "content/public/test/content_browser_test.h"
......@@ -112,11 +110,6 @@ class DumpAccessibilityTestBase : public ContentBrowserTest,
// The node filters loaded from the test file.
std::vector<AccessibilityTreeFormatter::NodeFilter> node_filters_;
#if defined(LEAK_SANITIZER) && !defined(OS_NACL)
// http://crbug.com/568674
ScopedLeakSanitizerDisabler lsan_disabler;
#endif
// The current tree-formatter and event-recorder factories.
AccessibilityTreeFormatter::FormatterFactory formatter_factory_;
AccessibilityEventRecorder::EventRecorderFactory event_recorder_factory_;
......
......@@ -15,6 +15,7 @@
#include <vector>
#include "base/command_line.h"
#include "base/debug/leak_annotations.h"
#include "base/no_destructor.h"
#include "base/optional.h"
#include "base/strings/string_number_conversions.h"
......@@ -23,6 +24,7 @@
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversion_utils.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_mode_observer.h"
#include "ui/accessibility/ax_node_data.h"
......@@ -285,6 +287,16 @@ const char* BuildDescriptionFromHeaders(AXPlatformNodeDelegate* delegate,
}
std::string result = base::JoinString(names, " ");
#if defined(LEAK_SANITIZER) && !defined(OS_NACL)
// http://crbug.com/982839
// atk_table_get_column_description and atk_table_get_row_description return
// const gchar*, which suggests the caller does not gain ownership of the
// returned string. The g_strdup below causes a new allocation, which does not
// fit that pattern and causes a leak in tests.
ScopedLeakSanitizerDisabler lsan_disabler;
#endif
return g_strdup(result.c_str());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment