ruby-changes:35917
From: akr <ko1@a...>
Date: Fri, 17 Oct 2014 21:52:45 +0900 (JST)
Subject: [ruby-changes:35917] akr:r47998 (trunk): * pack.c (pack_unpack): Add casts for char references for 'b' and 'h'.
akr 2014-10-17 21:52:26 +0900 (Fri, 17 Oct 2014) New Revision: 47998 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47998 Log: * pack.c (pack_unpack): Add casts for char references for 'b' and 'h'. Modified files: trunk/ChangeLog trunk/pack.c Index: ChangeLog =================================================================== --- ChangeLog (revision 47997) +++ ChangeLog (revision 47998) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Oct 17 21:49:52 2014 Tanaka Akira <akr@f...> + + * pack.c (pack_unpack): Add casts for char references for 'b' and 'h'. + Fri Oct 17 17:50:10 2014 Tanaka Akira <akr@f...> * Avoid undefined behaviors found by gcc -fsanitize=undefined. Index: pack.c =================================================================== --- pack.c (revision 47997) +++ pack.c (revision 47998) @@ -1343,7 +1343,7 @@ pack_unpack(VALUE str, VALUE fmt) https://github.com/ruby/ruby/blob/trunk/pack.c#L1343 t = RSTRING_PTR(bitstr); for (i=0; i<len; i++) { if (i & 7) bits >>= 1; - else bits = *s++; + else bits = (unsigned char)*s++; *t++ = (bits & 1) ? '1' : '0'; } } @@ -1385,7 +1385,7 @@ pack_unpack(VALUE str, VALUE fmt) https://github.com/ruby/ruby/blob/trunk/pack.c#L1385 if (i & 1) bits >>= 4; else - bits = *s++; + bits = (unsigned char)*s++; *t++ = hexdigits[bits & 15]; } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/