Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential memory leak in System.IO #1875

Merged
merged 10 commits into from
Apr 6, 2021

Conversation

morali
Copy link
Contributor

@morali morali commented Apr 6, 2021

Description

New implementation of System.IO allocates memory and frees it only if fatfs methods return without error. This can lead to memory leak, if for example f_open method fails. I added CLEANUP() sections in native methods for freeing memory allocated on heap and closing file handles.

Motivation and Context

Fixes memory leak in System.IO

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@nfbot nfbot added the Type: bug label Apr 6, 2021
@dnfadmin
Copy link

dnfadmin commented Apr 6, 2021

CLA assistant check
All CLA requirements met.

Automated fixes for code style.
@nfbot
Copy link
Member

nfbot commented Apr 6, 2021

@morali there are issues with the code style on the source files.
A PR was submitted with the code style fixes. Please review and merge the changes. See morali#1.

Make sure you are using the project code style. Check the details here.

morali and others added 3 commits April 6, 2021 08:16
…de6-0d8a-4b34-a959-9605400ce268

Code style fixes for nanoframework/nf-interpreter PR#1875
Automated fixes for code style.
@nfbot
Copy link
Member

nfbot commented Apr 6, 2021

@morali there are issues with the code style on the source files.
A PR was submitted with the code style fixes. Please review and merge the changes. See morali#2.

Make sure you are using the project code style. Check the details here.

…09f-840f-45fa-bed9-f3acdd33c3e0

Code style fixes for nanoframework/nf-interpreter PR#1875
@nanoframework nanoframework deleted a comment from nfbot Apr 6, 2021
@nanoframework nanoframework deleted a comment from nfbot Apr 6, 2021
@nanoframework nanoframework deleted a comment from nfbot Apr 6, 2021
Jeremi Jasiński and others added 3 commits April 6, 2021 08:52
@nfbot
Copy link
Member

nfbot commented Apr 6, 2021

@morali there are issues with the code style on the source files.
A PR was submitted with the code style fixes. Please review and merge the changes. See morali#3.

Make sure you are using the project code style. Check the details here.

…801-35a4-40eb-97c5-609a82603f13

Code style fixes for nanoframework/nf-interpreter PR#1875
@josesimoes josesimoes added Area: Common libs Everything related with common libraries and removed Area: Common libs Everything related with common libraries Type: enhancement labels Apr 6, 2021
Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! Thanks for taking care of this. 👏🏻 👍🏻

@josesimoes josesimoes changed the title Fixed memory leak in System.IO if error occurs in native methods Fix potential memory leak in System.IO Apr 6, 2021
@josesimoes josesimoes merged commit 009e477 into nanoframework:develop Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants