lairworks / nas2d-core

NAS2D is an open source, object oriented 2D game development framework written in portable C++.
http://nas2d.lairworks.com
zlib License
10 stars 6 forks source link

Fix `Filesystem` get paths bug #1140

Closed DanRStevens closed 1 year ago

DanRStevens commented 1 year ago

While investigating some failures for the Arch Linux build, we discovered we didn't properly check the return code for a couple of SDL path functions:

Both these functions can potentially return NULL if there was an error.

This can be an issue when run in a Docker container using a user ID for a user that doesn't exist in /etc/passwd in the container image. In particular the HOME environment variable may not be set, which can cause SDL_GetPrefPath to fail. Setting HOME to a path that is writable can allow the unit tests to work.

To better detect this situation, we convert the NULL error code to an exception with the message from SDL_GetError.