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

Improve memory checks #223

Merged
merged 3 commits into from
Feb 7, 2018
Merged

Improve memory checks #223

merged 3 commits into from
Feb 7, 2018

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Feb 7, 2018

By submitting this pull request, I confirm the following (please check boxes, eg [X]) Failure to fill the template will close your PR:

Please submit all pull requests against the development branch. Failure to do so will delay or deny your request

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

How familiar are you with the codebase?:

10


With this PR, we add our own memory handling functions that will detect possible errors and report accordingly in the log. This will make debugging FTL crashes caused by insufficient memory or by code bugs (not properly dealing with NULL pointers) much easier.

We also rename struct.c -> memory.c as this is a more obvious choice for a file that does only contain functions that deal with memory operations. Accordingly, I also move all validate_access* functions from parser.c to memory.c without changing them.

Furthermore, we add pointer validation for allocated memory in a few places where they have been missing, sometimes even when a NULL pointer would not be a problem.

If we cannot get this PR reviewed before the release of v3.0 then it should not be a blocker and can be directed for merging into development.

This template was created based on the work of udemy-dl.

DL6ER added 3 commits February 7, 2018 12:24
- calloc,
- realloc,
- free, and
- strdup

These functions will not directly improve memory handling but they will log if something will go wrong *before* it actually goes wrong. This will ease debugging when user provide log snippets especially in ENOMEM (no memory available) situations.

Signed-off-by: DL6ER <[email protected]>
…ion events at the places we need the allocated space

Signed-off-by: DL6ER <[email protected]>
@DL6ER DL6ER merged commit 454d968 into release/3.0 Feb 7, 2018
@DL6ER DL6ER deleted the fix/memory_checks branch February 7, 2018 21:35
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.

2 participants