Commit 77f668a0 authored by Ken Thompson's avatar Ken Thompson

added protection against race condition

between first and second pass of converting
[]int to string.

R=r
OCL=29467
CL=29467
parent 64c3fe05
......@@ -184,21 +184,25 @@ sys·arraystring(Array b, String s)
void
sys·arraystringi(Array b, String s)
{
int32 siz, i;
int32 siz1, siz2, i;
int32 *a;
byte dum[8];
a = (int32*)b.array;
siz = 0;
siz1 = 0;
for(i=0; i<b.nel; i++) {
siz += runetochar(dum, a[i]);
siz1 += runetochar(dum, a[i]);
}
s = gostringsize(siz);
siz = 0;
s = gostringsize(siz1+4);
siz2 = 0;
for(i=0; i<b.nel; i++) {
siz += runetochar(s.str+siz, a[i]);
// check for race
if(siz2 >= siz1)
break;
siz2 += runetochar(s.str+siz2, a[i]);
}
s.len = siz2;
FLUSH(&s);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment