The Static Code Analysis Tool (Fortify from HP) complains about WinForms code created by Visual Studio Designer when the Font property of any control is assigned. The analysis tool complains:
line 143: this.mCopyrightLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
The InitializeComponent () function in AboutWindowForm.cs cannot properly utilize the unmanaged system resources allocated by Font () on line 143.
Explanation:
A program cannot properly manage a managed entity that uses unmanaged system resources. Incorrect disposal of a managed object that uses unmanaged system resources has at least two common reasons:
- Error conditions and other exceptional circumstances.
- Confusion over which part of the program is responsible for freeing a resource.
In this case, there are programmatic paths where the resource allocated in AboutWindowForm.cs on line 143 is not deleted properly.
A small subset of .NET managed objects uses unmanaged system resources ... The Garbage Collector cannot release the original managed objects in a predictable way. Thus, the application may end up with available memory because the garbage collector is unaware of the memory consumed by unmanaged resources. Most unmanaged resource leakage problems lead to common software reliability issues, but if an attacker can intentionally trigger an unmanaged resource leak, an attacker can launch a denial of service attack by omitting an unmanaged resource pool.
- , :
- GDI, , , .
- GDI , WinForm .
- Dispose WinForms " "
- ,
, Font, VS- , , , , ?
Form: , , . GDI . , ?
, , . , GC. , , GC, GC , GC . .
, ? WinFroms? .
:
Font Dispose of Control Control release Font GC ?
!
:
, , : WinForm TaskManager, . , , . , , GDI TaskManager . .
, , GDI TaskManager . Font , , GC . ", " .
, Font, WinForms Control Font, , . , , ,
- WinForm , (, GC)
- Dispose a Control Font, Font ( , , GC)
+ . , , .