Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(397)

Issue 64370046: code review 64370046: cmd/gc: avoid pointer beyond array in range loop (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 4 months ago by rsc
Modified:
11 years, 4 months ago
Reviewers:
gobot, mtj1
CC:
ken2, golang-codereviews
Visibility:
Public.

Description

cmd/gc: avoid pointer beyond array in range loop This problem was discovered by reading the code. I have not seen it in practice, nor do I have any ideas on how to trigger it reliably in a test. But it's still worth fixing.

Patch Set 1 #

Patch Set 2 : diff -r b0ecc1786896 https://code.google.com/p/go/ #

Patch Set 3 : diff -r 8905c499a5e2 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+12 lines, -2 lines) Patch
M src/cmd/gc/range.c View 1 1 chunk +12 lines, -2 lines 0 comments Download

Messages

Total messages: 4
rsc
Hello ken2 (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
11 years, 4 months ago (2014-02-16 01:00:55 UTC) #1
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=2379f812d6b8 *** cmd/gc: avoid pointer beyond array in range loop This problem ...
11 years, 4 months ago (2014-02-16 01:01:00 UTC) #2
gobot
This CL appears to have broken the darwin-amd64 builder.
11 years, 4 months ago (2014-02-16 02:07:08 UTC) #3
mtj1
11 years, 4 months ago (2014-02-16 06:09:00 UTC) #4
FWIW, you could instead do:

if(i >= len(x)-1) break; p++; i++;

or

i++; if(i >= len(x)) break; p++;

and p would never point beyond the slice.
On Feb 15, 2014 6:07 PM, <gobot@golang.org> wrote:

> This CL appears to have broken the darwin-amd64 builder.
>
> https://codereview.appspot.com/64370046/
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-codereviews" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-codereviews+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b