If the input response object contains invalid XML, the invocation of reader.MoveToContent method can lead to an exception and the response object will not be properly disposed. One possible fix would be to wrap the reading part in try/catch block like the following:
https://github.com/microsoft/referencesource/blob/17b97365645da62cf8a49444d979f94a59bbb155/System.ServiceModel/System/ServiceModel/Description/MetadataExchangeClient.cs#L813
If the input
response
object contains invalid XML, the invocation ofreader.MoveToContent
method can lead to an exception and the response object will not be properly disposed. One possible fix would be to wrap the reading part in try/catch block like the following: