diff --git a/ChangeLog b/ChangeLog index 5db122c023..642dce5bda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Oct 17 21:49:52 2014 Tanaka Akira + + * pack.c (pack_unpack): Add casts for char references for 'b' and 'h'. + Fri Oct 17 17:50:10 2014 Tanaka Akira * Avoid undefined behaviors found by gcc -fsanitize=undefined. diff --git a/pack.c b/pack.c index d9283b7ea6..0cf2dc37b7 100644 --- a/pack.c +++ b/pack.c @@ -1343,7 +1343,7 @@ pack_unpack(VALUE str, VALUE fmt) t = RSTRING_PTR(bitstr); for (i=0; i>= 1; - else bits = *s++; + else bits = (unsigned char)*s++; *t++ = (bits & 1) ? '1' : '0'; } } @@ -1385,7 +1385,7 @@ pack_unpack(VALUE str, VALUE fmt) if (i & 1) bits >>= 4; else - bits = *s++; + bits = (unsigned char)*s++; *t++ = hexdigits[bits & 15]; } }