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 NullReferenceException on linux systems where the specified paths don't exist #1300

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Smightym8
Copy link

As mentioned in the issue #1178 it throws a NullReference Exception on linux systems if it can't find the specified path.

ReadFsSys now returns an empty string instead of null so that the switch case in the methods Identification.GetManufacturer and Identification.GetModel can end up in the default case instead of throwing a NullReference Exception.

In the LMSensors constructor it checks now if the hwmon directory exists before trying to get the sub directories.

…formation

Changed the ReadSysFs method in the class SMBios to return an empty string instead of null when unable to find the needed paths on Linux, preventing NullReference Exception when getting the manufacturer and model in the Motherboard class.
Introduced string array subDirectories  which is initialized empty. Added checking if the hwmon directory exists otherwise the array subDirectories will stay empty so it does not throw an exception if it can't find the path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant