diff options
-rw-r--r-- | ffi.c | 6 | ||||
-rw-r--r-- | stream.c | 8 |
2 files changed, 7 insertions, 7 deletions
@@ -62,7 +62,7 @@ #define alignof(type) offsetof(struct {char x; type y;}, y) -#define pad_retval(size) ((size) > sizeof (ffi_arg) \ +#define pad_retval(size) (convert(size_t, size) > sizeof (ffi_arg) \ ? (size) \ : sizeof (ffi_arg)) @@ -1295,7 +1295,7 @@ static void ffi_sbit_put(struct txr_ffi_type *tft, val n, int icheck = -(int)(((uput ^ mask) >> shift) + 1); if (icheck != cn) goto range; - } else if (uput >> shift != cn) { + } else if (convert(cnum, uput >> shift) != cn) { goto range; } @@ -2730,7 +2730,7 @@ static val make_ffi_type_struct(val syntax, val lisp_type, mtft->mask = ((1U << bits) - 1) << mtft->shift; bit_offs += bits; } else { - cnum align = mtft->align; + ucnum align = mtft->align; ucnum almask = align - 1; if (bit_offs > 0) { @@ -860,9 +860,9 @@ static val stdio_put_buf(val stream, val buf, cnum pos) ucnum len = c_unum(length_buf(buf)); mem_t *ptr = buf_get(buf, self); struct stdio_handle *h = coerce(struct stdio_handle *, stream->co.handle); - if ((size_t) len != len) + if ((size_t) len != len || len > INT_PTR_MAX) uw_throwf(error_s, lit("~a: buffer too large"), self, nao); - if (pos >= len) + if (convert(ucnum, pos) >= len) return num(len); errno = 0; if (h->f != 0) { @@ -880,9 +880,9 @@ static val stdio_fill_buf(val stream, val buf, cnum pos) ucnum len = c_unum(length_buf(buf)); mem_t *ptr = buf_get(buf, self); struct stdio_handle *h = coerce(struct stdio_handle *, stream->co.handle); - if ((size_t) len != len) + if ((size_t) len != len || len > INT_PTR_MAX) uw_throwf(error_s, lit("~a: buffer too large"), self, nao); - if (pos >= len) + if (convert(ucnum, pos) >= len) return num(len); errno = 0; if (h->f != 0) { |