Reputation: 1729
I have an application which is communicating via a COM Port.
When the user exits my application, should the app clean/close everything?
If I don't do this, is my application security compromised?
Upvotes: 0
Views: 447
Reputation: 7226
The general rule is to always close every resource. The thing is you can never really know if it could be exploited and how. But it's best not to take that chance.
When I work with IO, open streams and relatives I like to properly flush them and close them always. You can avoid some hard to identify bugs this way.
This is oftenly done in a finally
block for exactly that reason. If the execution throws exceptions or not, you want everything closed at the end.
Upvotes: 5