From 1efb3c31b731e99627bbc0da13dfd3463bb67c67 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 17 Oct 2014 08:50:01 +0000 Subject: * Avoid undefined behaviors found by gcc -fsanitize=undefined. gcc (Debian 4.9.1-16) 4.9.1 * include/ruby/ruby.h (INT2FIX): Avoid undefined behavior. * node.h (nd_set_line): Ditto. * pack.c (encodes): Ditto. (pack_unpack): Ditto. * regint.h (BIT_STATUS_AT): Ditto. (BS_BIT): Ditto. * time.c (time_mdump): Ditto. (time_mload): Ditto. * vm_core.h (VM_FRAME_MAGIC_MASK): Ditto. * vm_trace.c (recalc_add_ruby_vm_event_flags): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- pack.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'pack.c') diff --git a/pack.c b/pack.c index fcf3a3a2a0..d9283b7ea6 100644 --- a/pack.c +++ b/pack.c @@ -943,13 +943,14 @@ static const char b64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static void -encodes(VALUE str, const char *s, long len, int type, int tail_lf) +encodes(VALUE str, const char *s0, long len, int type, int tail_lf) { enum {buff_size = 4096, encoded_unit = 4, input_unit = 3}; char buff[buff_size + 1]; /* +1 for tail_lf */ long i = 0; const char *const trans = type == 'u' ? uu_table : b64_table; char padding; + const unsigned char *s = (const unsigned char *)s0; if (type == 'u') { buff[i++] = (char)len + ' '; @@ -1362,7 +1363,7 @@ pack_unpack(VALUE str, VALUE fmt) t = RSTRING_PTR(bitstr); for (i=0; i> 4) & 15]; } } -- cgit v1.2.3