From 6ddae25487d6d97f039b0ffa6f51ebf41b84513a Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 22 Aug 2018 15:25:55 -0400 Subject: [PATCH] config+cmd/lncli: make cleanAndExpandPath return empty string on empty path Co-Authored-By: Karl Ranna --- cmd/lncli/main.go | 5 ++++- config.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/lncli/main.go b/cmd/lncli/main.go index 4600c8ff..b0e6292d 100644 --- a/cmd/lncli/main.go +++ b/cmd/lncli/main.go @@ -252,10 +252,13 @@ func main() { // passed path, cleans the result, and returns it. // This function is taken from https://github.com/btcsuite/btcd func cleanAndExpandPath(path string) string { + if path == "" { + return "" + } + // Expand initial ~ to OS specific home directory. if strings.HasPrefix(path, "~") { var homeDir string - user, err := user.Current() if err == nil { homeDir = user.HomeDir diff --git a/config.go b/config.go index 10571f98..de339da5 100644 --- a/config.go +++ b/config.go @@ -934,10 +934,13 @@ func loadConfig() (*config, error) { // passed path, cleans the result, and returns it. // This function is taken from https://github.com/btcsuite/btcd func cleanAndExpandPath(path string) string { + if path == "" { + return "" + } + // Expand initial ~ to OS specific home directory. if strings.HasPrefix(path, "~") { var homeDir string - user, err := user.Current() if err == nil { homeDir = user.HomeDir