* pack.c (pack_unpack): Add casts for char references for 'b' and 'h'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0d4185f30e
commit
50650bb338
@ -1,3 +1,7 @@
|
|||||||
|
Fri Oct 17 21:49:52 2014 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* pack.c (pack_unpack): Add casts for char references for 'b' and 'h'.
|
||||||
|
|
||||||
Fri Oct 17 17:50:10 2014 Tanaka Akira <akr@fsij.org>
|
Fri Oct 17 17:50:10 2014 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* Avoid undefined behaviors found by gcc -fsanitize=undefined.
|
* Avoid undefined behaviors found by gcc -fsanitize=undefined.
|
||||||
|
4
pack.c
4
pack.c
@ -1343,7 +1343,7 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||||||
t = RSTRING_PTR(bitstr);
|
t = RSTRING_PTR(bitstr);
|
||||||
for (i=0; i<len; i++) {
|
for (i=0; i<len; i++) {
|
||||||
if (i & 7) bits >>= 1;
|
if (i & 7) bits >>= 1;
|
||||||
else bits = *s++;
|
else bits = (unsigned char)*s++;
|
||||||
*t++ = (bits & 1) ? '1' : '0';
|
*t++ = (bits & 1) ? '1' : '0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1385,7 +1385,7 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||||||
if (i & 1)
|
if (i & 1)
|
||||||
bits >>= 4;
|
bits >>= 4;
|
||||||
else
|
else
|
||||||
bits = *s++;
|
bits = (unsigned char)*s++;
|
||||||
*t++ = hexdigits[bits & 15];
|
*t++ = hexdigits[bits & 15];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user