diff options
author | Fabricio Voznika <fvoznika@google.com> | 2020-09-22 13:43:02 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-09-22 13:45:24 -0700 |
commit | 778c367171f96c6cfd269cd2363c9f608dd96bcb (patch) | |
tree | 1b7eeb9ee7ea511b5c3da439d424d6cbb7d86f39 | |
parent | 6e5ea605f4ca9fb8c29adc9510edc980f844ddfc (diff) |
Fix panic in `runsc flags`
When printing flags, FlagSet.PrintDefaults compares the Zero
value to the flag default value. The Zero refs.LeakMode value
was panicking in String() because it didn't expect the default
to be used
Closes #4023
PiperOrigin-RevId: 333150836
-rw-r--r-- | pkg/refs/refcounter.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/pkg/refs/refcounter.go b/pkg/refs/refcounter.go index 57d8542b9..699ea8ac3 100644 --- a/pkg/refs/refcounter.go +++ b/pkg/refs/refcounter.go @@ -257,6 +257,8 @@ func (l *LeakMode) Get() interface{} { // String implements flag.Value. func (l *LeakMode) String() string { switch *l { + case UninitializedLeakChecking: + return "uninitialized" case NoLeakChecking: return "disabled" case LeaksLogWarning: @@ -264,7 +266,7 @@ func (l *LeakMode) String() string { case LeaksLogTraces: return "log-traces" } - panic(fmt.Sprintf("invalid ref leak mode %q", *l)) + panic(fmt.Sprintf("invalid ref leak mode %d", *l)) } // leakMode stores the current mode for the reference leak checker. |