supertux icon indicating copy to clipboard operation
supertux copied to clipboard

Fix windows crash viewer

Open MatusGuy opened this issue 1 year ago • 12 comments

MatusGuy avatar Jun 26 '24 17:06 MatusGuy

finally!

NickerAban avatar Jun 26 '24 21:06 NickerAban

wtfreaky

MatusGuy avatar Jun 27 '24 10:06 MatusGuy

@tobbi How can I ignore the cppcheck errors?

MatusGuy avatar Aug 17 '24 11:08 MatusGuy

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

tobbi avatar Aug 17 '24 11:08 tobbi

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

MatusGuy avatar Aug 17 '24 11:08 MatusGuy

I think it can still be empty

tobbi avatar Aug 17 '24 11:08 tobbi

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

MatusGuy avatar Aug 17 '24 12:08 MatusGuy

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

tobbi avatar Aug 17 '24 12:08 tobbi

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

MatusGuy avatar Aug 17 '24 12:08 MatusGuy

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

tobbi avatar Aug 17 '24 21:08 tobbi

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

MatusGuy avatar Aug 17 '24 21:08 MatusGuy

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

tobbi avatar Aug 17 '24 22:08 tobbi