Index: lib/Sema/SemaDeclAttr.cpp
===================================================================
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1311,8 +1311,8 @@ void Sema::AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
 /// Normalize the attribute, __foo__ becomes foo.
 /// Returns true if normalization was applied.
 static bool normalizeName(StringRef &AttrName) {
-  if (AttrName.startswith("__") && AttrName.endswith("__")) {
-    assert(AttrName.size() > 4 && "Name too short");
+  if (AttrName.size() > 4 && AttrName.startswith("__") &&
+      AttrName.endswith("__")) {
     AttrName = AttrName.drop_front(2).drop_back(2);
     return true;
   }
Index: test/Sema/attr-ownership.c
===================================================================
--- test/Sema/attr-ownership.c
+++ test/Sema/attr-ownership.c
@@ -22,3 +22,4 @@ void f15(int, int)
   __attribute__((ownership_returns(foo, 1)))  // expected-note {{declared with index 1 here}}
   __attribute__((ownership_returns(foo, 2))); // expected-error {{'ownership_returns' attribute index does not match; here it is 2}}
 void f16(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_holds(foo, 1))); // OK, same index
+void f17(void*) __attribute__((ownership_takes(__, 1)));
