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

[BUG] Windows code returns a pointer to the stack, Mac has a use after free #53

Open
rj45 opened this issue May 18, 2024 · 1 comment
Open
Labels
bug Something isn't working macOS Mac-specific issue todo To be worked on windows Windows-specific issue

Comments

@rj45
Copy link

rj45 commented May 18, 2024

The dialog struct has the filename set to a pointer to stack memory:

char file[NVDIALOG_MAXBUF];

Then at the end of the function, the pointer is returned without copying the memory to the heap:

dialog->filename = ofn.lpstrFile;
dialog->location_was_chosen = true;
*savebuf = dialog->filename;

There's a similar issue with the Mac version where the memory for the filename string will be freed before the function returns. In both cases I had to strdup() the string and return that.

The gtk version and sandbox version both correctly strdup() the filename. I don't fully understand the adw code but it looks like it might also be missing a strdup().

@rj45 rj45 added the bug Something isn't working label May 18, 2024
@tseli0s tseli0s added todo To be worked on windows Windows-specific issue macOS Mac-specific issue labels May 23, 2024
@tseli0s
Copy link
Owner

tseli0s commented May 23, 2024

The dialog struct has the filename set to a pointer to stack memory:

We no longer use the backend-specific implementations on any backend. See src/impl/nvdialog_typeimpl.h, that's where the types are implemented now. In other words, you're looking at the wrong type.

I don't know about the macos backend (Are you talking about #55 ?), but the backend for MacOS is generally abandoned due to lack of maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working macOS Mac-specific issue todo To be worked on windows Windows-specific issue
Projects
None yet
Development

No branches or pull requests

2 participants