boostorg / compute

A C++ GPU Computing Library for OpenCL
http://boostorg.github.io/compute/
Boost Software License 1.0
1.52k stars 333 forks source link

Check for nullptr when getting appdata_path #884

Open dmedora opened 3 months ago

dmedora commented 3 months ago

At present, there is no check to ensure std::getenv has returned a non-null value in [detail::getenv]()https://github.com/boostorg/compute/blob/36350b7de849300bd3d72a05d8bf890ca405a014/include/boost/compute/detail/getenv.hpp#L26.

If it is unable to find the APPDATA or HOME env var, it returns a nullptr. appdata_path then tries to use this nullptr to build a string. Updated appdata_path to log an error if a nullptr is returned.

(Context: ran into an issue with this while using LightGBM where the program was unexpectedly crashing without any error due to $HOME not being set.)