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

datastorage: fix use-after-free compiler error #199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mmtj
Copy link
Contributor

@mmtj mmtj commented Oct 23, 2022

I am not familiar with how are dawn_regmem() and dawn_unregmem() supposed to be used, so I might be wrong.

Nevertheless, it seems odd to use FILE * fp pointer after fclose(), regardless how it is supposed to be handled in dawn_unregmem().

This should fix the "use-after-free" compiler error.

Closes: #198

@mmtj mmtj force-pushed the fix/datastorage-use-after-free branch from dbb9d00 to 8bb950b Compare October 23, 2022 20:13
@mmtj mmtj changed the title datastorage.c: fix use-after-free compiler error datastorage: fix use-after-free compiler error Oct 23, 2022
@mmtj mmtj force-pushed the fix/datastorage-use-after-free branch from 8bb950b to a1b8ae1 Compare October 23, 2022 22:30
@Flole998
Copy link
Contributor

This is actually intended, the (un)reg_mem() functions keep track of memory usage, it is intended to be used as a memory leak detector and should be called after the memory is freed.

@PolynomialDivision
Copy link
Collaborator

Yes. Have a look here:
58861a1

@mmtj mmtj force-pushed the fix/datastorage-use-after-free branch from a1b8ae1 to a411762 Compare April 20, 2023 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build fails on -Werror=use-after-free on GCC 12.2.0
3 participants