cli/compose/types: UlimitsConfig.MarshalYAML() fix recursion
When marshaling the type with `gopkg.in/yaml.v3`, unmarshaling would recursively call the type's `MarshalYAML()` function, which ultimately resulted in a crash: runtime: goroutine stack exceeds 1000000000-byte limit runtime: sp=0x140202e0430 stack=[0x140202e0000, 0x140402e0000] fatal error: stack overflow This applies a similar fix as was implemented in e7788d6f9a61d67566518efe11e394c414a21173 for the `MarshalJSON()` implementation. An alternative would be to use a type alias (to remove the `MarshalYAML()`), but keeping it simple. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c18dd2719e
commit
0644aa3906
@ -441,7 +441,8 @@ func (u *UlimitsConfig) MarshalYAML() (interface{}, error) {
|
|||||||
if u.Single != 0 {
|
if u.Single != 0 {
|
||||||
return u.Single, nil
|
return u.Single, nil
|
||||||
}
|
}
|
||||||
return u, nil
|
// Return as a value to avoid re-entering this method and use the default implementation
|
||||||
|
return *u, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON makes UlimitsConfig implement json.Marshaller
|
// MarshalJSON makes UlimitsConfig implement json.Marshaller
|
||||||
|
Loading…
x
Reference in New Issue
Block a user