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 windows crash viewer #2987

Merged
merged 16 commits into from
Oct 6, 2024
Merged

Conversation

MatusGuy
Copy link
Member

No description provided.

@NickerAban
Copy link

finally!

@MatusGuy
Copy link
Member Author

wtfreaky

@mrkubax10 mrkubax10 added os:windows type:patch status:in-progress Progress has been done, but more is intended be done category:code labels Jul 25, 2024
@MatusGuy
Copy link
Member Author

@tobbi How can I ignore the cppcheck errors?

@tobbi
Copy link
Member

tobbi commented Aug 17, 2024

Can you not simply fix them? Add a check for the path being empty?

@MatusGuy
Copy link
Member Author

I still need to pass &path[0] which shouldn't cause issues anyway because I already reserve MAX_PATH bytes

@tobbi
Copy link
Member

tobbi commented Aug 17, 2024

I think it can still be empty

@MatusGuy
Copy link
Member Author

The contents of the string are empty but the size isn't. path[0] would probably just give a null character

@tobbi
Copy link
Member

tobbi commented Aug 17, 2024

14:20:39] Tobbi: If I have an std::string and call reserve on it, can &path[0] still be out of bounds if the string itself is empty
[14:32:43] PJBoy: yeah
[14:32:58] PJBoy: well
[14:33:05] PJBoy: you can take the address just fine
[14:33:30] PJBoy: and if you make the string non-empty without exceeding the capacity you reserved, that address will become dereferencable

@MatusGuy
Copy link
Member Author

Alright then how do I check if the string is invalid before passing it into GetModuleFileName (the function that fills the string)?

@tobbi
Copy link
Member

tobbi commented Aug 17, 2024

Just check the length: https://cplusplus.com/reference/string/string/length/

@MatusGuy
Copy link
Member Author

If GetModuleFileName fills the string then won't checking for the length of the string always reach the same result?

@tobbi
Copy link
Member

tobbi commented Aug 17, 2024

Just check whether it's greater than 0, to silence the warning.

@MatusGuy MatusGuy marked this pull request as ready for review October 5, 2024 10:04
@MatusGuy MatusGuy merged commit 66a150b into SuperTux:master Oct 6, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:code os:windows status:in-progress Progress has been done, but more is intended be done type:patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants