Failing to close files when they are no longer needed may allow attackers to exhaust, and possibly manipulate system resources. This phenomenon is typically referred to as file descriptor leakage, although file pointers can may also be used as an attack vector (depending on the underlying system). To prevent file descriptor leaks, file pointers and file descriptors should be closed when they are no longer needed.
...