Skip to content

Commit 57b2477

Browse files
committed
Fix infinite loop in 'gh release list --limit 0'
Other list subcommands correctly reject --limit 0 but 'release list' does not validate the limit, causing an infinite loop. Add validation consistent with other subcommands and a test. Closes cli#13078
1 parent 5d3c2ba commit 57b2477

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

pkg/cmd/release/list/list.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
4444
// support `-R, --repo` override
4545
opts.BaseRepo = f.BaseRepo
4646

47+
if opts.LimitResults < 1 {
48+
return cmdutil.FlagErrorf("invalid limit: %v", opts.LimitResults)
49+
}
50+
4751
if runF != nil {
4852
return runF(opts)
4953
}

pkg/cmd/release/list/list_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ func Test_NewCmdList(t *testing.T) {
5858
Order: "desc",
5959
},
6060
},
61+
{
62+
name: "zero limit",
63+
args: "--limit 0",
64+
wantErr: "invalid limit: 0",
65+
},
6166
{
6267
name: "with order",
6368
args: "--order asc",

0 commit comments

Comments
 (0)