diff options
author | Atsushi Eno <atsushieno@veritas-vos-liberabit.com> | 2013-02-27 11:50:54 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@veritas-vos-liberabit.com> | 2013-02-27 11:50:54 +0400 |
commit | beefa7d3207edb359db4c77d594ac074d29a5a67 (patch) | |
tree | d9cfa68acb358fad63d216c192ae5e16aed4bf5d /mcs/class/System.XML/System.Xml | |
parent | 241d34dd7c1faae06f88d3fe2d741f4f24751bcf (diff) |
Fix possible NRE caused by null XmlResolver settings.
Diffstat (limited to 'mcs/class/System.XML/System.Xml')
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlTextReader.cs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs index 0f9a96ac992..63745fe3039 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextReader.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs @@ -166,7 +166,7 @@ namespace Mono.Xml2 Uri ResolveUri (string url) { - return resolver.ResolveUri (null, url); + return resolver == null ? null : resolver.ResolveUri (null, url); } Stream GetStreamFromUrl (string url, out string absoluteUriString) @@ -179,7 +179,7 @@ namespace Mono.Xml2 #endif Uri uri = ResolveUri (url); absoluteUriString = uri != null ? uri.ToString () : String.Empty; - return resolver.GetEntity (uri, null, typeof (Stream)) as Stream; + return resolver == null ? null : resolver.GetEntity (uri, null, typeof (Stream)) as Stream; } #endregion @@ -1183,7 +1183,10 @@ namespace Mono.Xml2 Uri uri = reader_uri; reader_uri = null; string uriString; - reader = new XmlStreamReader (GetStreamFromUrl (uri.ToString (), out uriString)); + Stream stream = GetStreamFromUrl (uri.ToString (), out uriString); + if (stream == null) + return false; + reader = new XmlStreamReader (stream); } if (peekCharsLength < 0) { // initialized buffer peekCharsLength = reader.Read (peekChars, 0, peekChars.Length); |