mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-13 11:09:23 +01:00
cmd+docs: fix cap out of range error in profile command
If `lncli profile remove` is called when there are no existing profiles, it will cause a "cap out of range" panic. So in this commit, a length check is added to avoid this.
This commit is contained in:
parent
9f013f5058
commit
96021fe85b
2 changed files with 7 additions and 0 deletions
|
@ -199,6 +199,10 @@ func profileRemove(ctx *cli.Context) error {
|
|||
return fmt.Errorf("name argument missing")
|
||||
}
|
||||
|
||||
if len(f.Profiles) == 0 {
|
||||
return fmt.Errorf("there are no existing profiles")
|
||||
}
|
||||
|
||||
// Create a copy of all profiles but don't include the one to delete.
|
||||
newProfiles := make([]*profileEntry, 0, len(f.Profiles)-1)
|
||||
for _, p := range f.Profiles {
|
||||
|
|
|
@ -57,6 +57,9 @@ minimum version needed to build the project.
|
|||
* [Fix](https://github.com/lightningnetwork/lnd/pull/6858) command line argument
|
||||
parsing for `lncli sendpayment`.
|
||||
|
||||
* [Fix](https://github.com/lightningnetwork/lnd/pull/6875) mapslice cap out of
|
||||
range error that occurs if the number of profiles is zero.
|
||||
|
||||
## Code Health
|
||||
|
||||
* [test: use `T.TempDir` to create temporary test
|
||||
|
|
Loading…
Add table
Reference in a new issue