1

when I ran the scan from veracode , i found the issue like Improper Resource Shutdown or Release , i tried finding the result from other blogs but i didn't get the solution. below is my code which is pointing at the issue. please suggest if i need to change/alter the code

private sealed class StreamWriter : IDisposable
{
    private MemoryStream memoryStream;
            

            private StreamWriter()
            {
              //Pointing the Improper Resource Shutdown or Release here
              memoryStream = new MemoryStream();
            }

            ~StreamWriter()
            {
                this.Dispose(false);
            }

            private void Dispose(bool disposing)
            {
                if (disposing)
                {
                    if (memoryStream != null)
                    {
                        memoryStream.Dispose();
                        memoryStream = null;
                    }
                }
            }
}  
Sri
  • 11
  • 2

0 Answers0