Skip to content

Commit

Permalink
Dispose XMLReader after using in Xml/Utils.cs (#103236)
Browse files Browse the repository at this point in the history
They are IDisposables and should be Dispose()d after being used to avoid
resource leaks.
  • Loading branch information
omajid authored Jun 13, 2024
1 parent 3f9a441 commit f821a7d
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ internal static XmlDocument PreProcessDocumentInput(XmlDocument document, XmlRes
settings.DtdProcessing = DtdProcessing.Parse;
settings.MaxCharactersFromEntities = MaxCharactersFromEntities;
settings.MaxCharactersInDocument = MaxCharactersInDocument;
XmlReader reader = XmlReader.Create(stringReader, settings, baseUri);
using XmlReader reader = XmlReader.Create(stringReader, settings, baseUri);
doc.Load(reader);
}
return doc;
Expand All @@ -235,7 +235,7 @@ internal static XmlDocument PreProcessElementInput(XmlElement elem, XmlResolver
settings.DtdProcessing = DtdProcessing.Parse;
settings.MaxCharactersFromEntities = MaxCharactersFromEntities;
settings.MaxCharactersInDocument = MaxCharactersInDocument;
XmlReader reader = XmlReader.Create(stringReader, settings, baseUri);
using XmlReader reader = XmlReader.Create(stringReader, settings, baseUri);
doc.Load(reader);
}
return doc;
Expand Down

0 comments on commit f821a7d

Please sign in to comment.