1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-29 13:39:10 +00:00

Fixed #373, segmentation fault when HOME is unset (#375)

This commit is contained in:
Kevin Mooney 2018-01-19 14:06:55 +00:00 committed by Brenden Matthews
parent e1f38f9b68
commit 49daff2ced

View File

@ -130,11 +130,12 @@ double get_time(void)
return tv.tv_sec + (tv.tv_nsec * 1e-9);
}
/* Converts '~/...' paths to '/home/blah/...'
* It's similar to variable_substitute, except only cheques for $HOME and ~/ in path */
/* Converts '~/...' paths to '/home/blah/...'. It's similar to
* variable_substitute, except only cheques for $HOME and ~/ in
* path. If HOME is unset it uses an empty string for substitution */
std::string to_real_path(const std::string &source)
{
const char *homedir = getenv("HOME");
const char *homedir = getenv("HOME") ? : "";
if(source.find("~/") == 0)
return homedir + source.substr(1);
else if(source.find("$HOME/") == 0)