Bläddra i källkod

2009-01-20 Atsushi Enomoto <[email protected]>

	* XmlDocumentNavigator.cs : in some corner cases an attribute
	  may have null OwnerElement. Fixed bug #458245.

	* SelectNodesTests.cs : added test for bug #458245.


svn path=/trunk/mcs/; revision=123868
Atsushi Eno 17 år sedan
förälder
incheckning
29dd077cdd

+ 5 - 0
mcs/class/System.XML/System.Xml/ChangeLog

@@ -1,3 +1,8 @@
+2009-01-20  Atsushi Enomoto  <[email protected]>
+
+	* XmlDocumentNavigator.cs : in some corner cases an attribute
+	  may have null OwnerElement. Fixed bug #458245.
+
 2009-01-20  Atsushi Enomoto  <[email protected]>
 
 	* XmlReaderBinarySupport.cs : do not hang in the middle of reading

+ 2 - 0
mcs/class/System.XML/System.Xml/XmlDocumentNavigator.cs

@@ -628,6 +628,8 @@ namespace System.Xml
 		{
 			XmlAttribute attr = node as XmlAttribute;
 			XmlNode tmp = attr != null ? attr.OwnerElement : node;
+			if (tmp == null)
+				return; // i.e. attr has null OwnerElement.
 			for (XmlNode tmp2 = GetParentNode (tmp); tmp2 != null; tmp2 = GetParentNode (tmp2))
 				tmp = tmp2;
 			node = tmp;

+ 4 - 0
mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog

@@ -1,3 +1,7 @@
+2009-01-20  Atsushi Enomoto <[email protected]>
+
+	* SelectNodesTests.cs : added test for bug #458245.
+
 2008-12-09  Atsushi Enomoto <[email protected]>
 
 	* XPathNavigatorTests.cs : added test fo bug #456103.

+ 9 - 0
mcs/class/System.XML/Test/System.Xml.XPath/SelectNodesTests.cs

@@ -293,5 +293,14 @@ namespace MonoTests.System.Xml.XPath
 			AssertEquals ("bar", ans [0].Name);
 			AssertEquals ("baz", ans [1].Name);
 		}
+
+		[Test] // bug #458245
+		public void SelectFromDetachedAttribute ()
+		{
+			XmlDocument doc = new XmlDocument ();
+			doc.LoadXml ("<a></a>");
+			XmlNode attr = doc.CreateAttribute ("b");
+			attr.SelectSingleNode ("//*[@id='foo']");
+		}
 	}
 }