[llvm-commits] [compiler-rt] r172187 - in /compiler-rt/trunk/lib/sanitizer_common: sanitizer_list.h tests/sanitizer_list_test.cc
Dmitry Vyukov
dvyukov at google.com
Fri Jan 11 02:15:13 PST 2013
Author: dvyukov
Date: Fri Jan 11 04:15:13 2013
New Revision: 172187
URL: http://llvm.org/viewvc/llvm-project?rev=172187&view=rev
Log:
asan/tsan: fix bug in list implementation
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_list.h
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_list_test.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_list.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_list.h?rev=172187&r1=172186&r2=172187&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_list.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_list.h Fri Jan 11 04:15:13 2013
@@ -72,6 +72,8 @@
void append_front(IntrusiveList<Item> *l) {
CHECK_NE(this, l);
+ if (l->empty())
+ return;
if (empty()) {
*this = *l;
} else if (!l->empty()) {
@@ -84,6 +86,8 @@
void append_back(IntrusiveList<Item> *l) {
CHECK_NE(this, l);
+ if (l->empty())
+ return;
if (empty()) {
*this = *l;
} else {
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_list_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_list_test.cc?rev=172187&r1=172186&r2=172187&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_list_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_list_test.cc Fri Jan 11 04:15:13 2013
@@ -154,4 +154,21 @@
CHECK(l2.empty());
}
+TEST(SanitizerCommon, IntrusiveListAppendEmpty) {
+ ListItem i;
+ List l;
+ l.clear();
+ l.push_back(&i);
+ List l2;
+ l2.clear();
+ l.append_back(&l2);
+ CHECK_EQ(l.back(), &i);
+ CHECK_EQ(l.front(), &i);
+ CHECK_EQ(l.size(), 1);
+ l.append_front(&l2);
+ CHECK_EQ(l.back(), &i);
+ CHECK_EQ(l.front(), &i);
+ CHECK_EQ(l.size(), 1);
+}
+
} // namespace __sanitizer
More information about the llvm-commits
mailing list