• Martin Möhrmann's avatar
    runtime: avoid infinite loop in growslice · f3e0d143
    Martin Möhrmann authored
    On 386 the below code triggered an infinite loop in growslice:
    x = make([]byte, 1<<30-1, 1<<30-1)
    x = append(x, x...)
    
    Check for overflow when calculating the new slice capacity
    and set the new capacity to the requested capacity when an overflow
    is detected to avoid an infinite loop.
    
    No automatic test added due to requiring to allocate 1GB of memory
    on a 32bit plaform before use of append is able to trigger the
    overflow check.
    
    Fixes #21441
    
    Change-Id: Ia871cc9f88479dacf2c7044531b233f83d2fcedf
    Reviewed-on: https://go-review.googlesource.com/57950
    Run-TryBot: Martin Möhrmann <moehrmann@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarMarvin Stenger <marvin.stenger94@gmail.com>
    Reviewed-by: 's avatarKeith Randall <khr@golang.org>
    f3e0d143
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...