open-license-manager / licensecc

Software licensing, copy protection in C++. It has few dependencies and it's cross-platform.
http://open-license-manager.github.io/licensecc/
BSD 3-Clause "New" or "Revised" License
947 stars 300 forks source link

Exceptions not caught: `get_file_contents` throws char * but dmi_info catches std::string #112

Closed mharshe closed 3 years ago

mharshe commented 3 years ago

In Linux, the exceptions thrown using std::strerror (in file_utils.cpp) are caught in the DmiInfo class by value using std::string e. This is not caught correctly because std::strerror returns a char *.

I suggest changing this to throw like this:

throw(std::runtime_error(std::strerror(errno)));

and catch the exceptions using:

catch (const std::exception& e)