]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix integer overflow
authorDmitriy Vyukov <dvyukov@google.com>
Fri, 8 Feb 2013 15:05:19 +0000 (19:05 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Fri, 8 Feb 2013 15:05:19 +0000 (19:05 +0400)
The problem happens when end=0, then end-1 is very big number.
Observed with the new scheduler.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7307073

src/pkg/runtime/parfor.c

index 36dd65852fa6f3651084ab24eb695440894f954a..d146727430f41f18bbc90786ef388f1c80c9554f 100644 (file)
@@ -145,7 +145,7 @@ runtime·parfordo(ParFor *desc)
                                // See if it has any work.
                                begin = (uint32)pos;
                                end = (uint32)(pos>>32);
-                               if(begin >= end-1) {
+                               if(begin+1 >= end) {
                                        begin = end = 0;
                                        break;
                                }