mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
Potential fix for code scanning alert no. 5: Size computation for allocation may overflow
Romeo Rosete Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
parent
def873259a
commit
a32388b614
1 changed files with 3 additions and 0 deletions
|
|
@ -82,6 +82,9 @@ func MustDecode(input string) []byte {
|
|||
|
||||
// Encode encodes b as a hex string with 0x prefix.
|
||||
func Encode(b []byte) string {
|
||||
if len(b) > (int(^uint(0) >> 1))/2 {
|
||||
panic("input too large to encode as hex string")
|
||||
}
|
||||
enc := make([]byte, len(b)*2+2)
|
||||
copy(enc, "0x")
|
||||
hex.Encode(enc[2:], b)
|
||||
|
|
|
|||
Loading…
Reference in a new issue