Fixes for clang -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error

Fixes 'Illegal instruction' when SWIG executes and compiled with above
compiler options

Fixes #263
This commit is contained in:
William S Fulton 2014-11-08 10:53:49 +00:00
commit 220acc3fc8

View file

@ -181,10 +181,10 @@ static int String_hash(DOH *so) {
return s->hashkey;
} else {
register char *c = s->str;
register int len = s->len > 50 ? 50 : s->len;
register int h = 0;
register int mlen = len >> 2;
register int i = mlen;
register unsigned int len = s->len > 50 ? 50 : s->len;
register unsigned int h = 0;
register unsigned int mlen = len >> 2;
register unsigned int i = mlen;
for (; i; --i) {
h = (h << 5) + *(c++);
h = (h << 5) + *(c++);
@ -195,7 +195,7 @@ static int String_hash(DOH *so) {
h = (h << 5) + *(c++);
}
h &= 0x7fffffff;
s->hashkey = h;
s->hashkey = (int)h;
return h;
}
}