Project

General

Profile

Bug #7744 ยป 242.patch

zzak (zzak _), 01/28/2013 02:14 AM

View differences:

time.c
static void
time_overflow_p(time_t *secp, long *nsecp)
{
time_t tmp, sec = *secp;
time_t sec = *secp;
long nsec = *nsecp;
if (nsec >= 1000000000) { /* nsec positive overflow */
tmp = sec + nsec / 1000000000;
nsec %= 1000000000;
if (sec > 0 && tmp < 0) {
if (sec > TIMET_MAX - nsec / 1000000000) {
rb_raise(rb_eRangeError, "out of Time range");
}
sec = tmp;
sec += nsec / 1000000000;
nsec %= 1000000000;
}
if (nsec < 0) { /* nsec negative overflow */
tmp = sec + NDIV(nsec,1000000000); /* negative div */
nsec = NMOD(nsec,1000000000); /* negative mod */
if (sec < 0 && tmp > 0) {
if (sec < TIMET_MIN - NDIV(nsec,1000000000)) {
rb_raise(rb_eRangeError, "out of Time range");
}
sec = tmp;
sec += NDIV(nsec,1000000000); /* negative div */
nsec = NMOD(nsec,1000000000); /* negative mod */
}
#ifndef NEGATIVE_TIME_T
if (sec < 0)
-
ext/openssl/ossl.c
string2hex(const unsigned char *buf, int buf_len, char **hexbuf, int *hexbuf_len)
{
static const char hex[]="0123456789abcdef";
int i, len = 2 * buf_len;
int i, len;
if (buf_len < 0 || len < buf_len) { /* PARANOIA? */
if (buf_len < 0 || buf_len > INT_MAX / 2) { /* PARANOIA? */
return -1;
}
len = 2 * buf_len;
if (!hexbuf) { /* if no buf, return calculated len */
if (hexbuf_len) {
*hexbuf_len = len;
-
ext/bigdecimal/bigdecimal.c
return VpConstOne;
}
#define SIGNED_VALUE_MAX (SIGNED_VALUE)((~(VALUE)0) >> 1)
#define SIGNED_VALUE_MIN (SIGNED_VALUE)(~((~(VALUE)0) >> 1))
/* If exponent overflows,then raise exception or returns 0 */
static int
AddExponent(Real *a, SIGNED_VALUE n)
{
SIGNED_VALUE e = a->exponent;
SIGNED_VALUE m = e+n;
SIGNED_VALUE eb, mb;
if(e>0) {
if(n>0) {
mb = m*(SIGNED_VALUE)BASE_FIG;
eb = e*(SIGNED_VALUE)BASE_FIG;
if(mb<eb) goto overflow;
}
} else if(n<0) {
mb = m*(SIGNED_VALUE)BASE_FIG;
eb = e*(SIGNED_VALUE)BASE_FIG;
if(mb>eb) goto underflow;
if (n > 0) {
if (e > SIGNED_VALUE_MAX / BASE_FIG - n)
goto overflow;
} else {
if (e < SIGNED_VALUE_MIN / BASE_FIG - n)
goto underflow;
}
a->exponent = m;
a->exponent = e + n;
return 1;
/* Overflow/Underflow ==> Raise exception or returns 0 */
    (1-1/1)