Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #19 from Intel-HLS/missing_env_vars
Browse files Browse the repository at this point in the history
getenv() may return NULL if a variable isn't defined - this happens for
  • Loading branch information
stavrospapadopoulos committed May 10, 2016
2 parents fbc1d53 + 4f2b9ad commit ba6dcdb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/src/misc/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,8 @@ int read_from_file_with_mmap(
std::string real_dir(const std::string& dir) {
// Initialize current, home and root
std::string current = current_dir();
std::string home = getenv("HOME");
auto env_home_ptr = getenv("HOME");
std::string home = env_home_ptr ? env_home_ptr : current;
std::string root = "/";

// Easy cases
Expand Down
3 changes: 2 additions & 1 deletion core/src/storage_manager/storage_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ int StorageManager::init(const char* config_filename) {
// Set the TileDB home directory
tiledb_home_ = TILEDB_HOME;
if(tiledb_home_ == "") {
tiledb_home_ = getenv("HOME");
auto env_home_ptr = getenv("HOME");
tiledb_home_ = env_home_ptr ? env_home_ptr : "";
if(tiledb_home_ == "") {
char cwd[1024];
if(getcwd(cwd, sizeof(cwd)) != NULL) {
Expand Down

0 comments on commit ba6dcdb

Please sign in to comment.