diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/alloc.c b/src/alloc.c index 29393deeff4..17ca5c725d0 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -863,7 +863,7 @@ xnmalloc (ptrdiff_t nitems, ptrdiff_t item_size) | |||
| 863 | { | 863 | { |
| 864 | eassert (0 <= nitems && 0 < item_size); | 864 | eassert (0 <= nitems && 0 < item_size); |
| 865 | ptrdiff_t nbytes; | 865 | ptrdiff_t nbytes; |
| 866 | if (INT_MULTIPLY_WRAPV (nitems, item_size, &nbytes) || SIZE_MAX < nbytes) | 866 | if (ckd_mul (&nbytes, nitems, item_size) || SIZE_MAX < nbytes) |
| 867 | memory_full (SIZE_MAX); | 867 | memory_full (SIZE_MAX); |
| 868 | return xmalloc (nbytes); | 868 | return xmalloc (nbytes); |
| 869 | } | 869 | } |
| @@ -877,7 +877,7 @@ xnrealloc (void *pa, ptrdiff_t nitems, ptrdiff_t item_size) | |||
| 877 | { | 877 | { |
| 878 | eassert (0 <= nitems && 0 < item_size); | 878 | eassert (0 <= nitems && 0 < item_size); |
| 879 | ptrdiff_t nbytes; | 879 | ptrdiff_t nbytes; |
| 880 | if (INT_MULTIPLY_WRAPV (nitems, item_size, &nbytes) || SIZE_MAX < nbytes) | 880 | if (ckd_mul (&nbytes, nitems, item_size) || SIZE_MAX < nbytes) |
| 881 | memory_full (SIZE_MAX); | 881 | memory_full (SIZE_MAX); |
| 882 | return xrealloc (pa, nbytes); | 882 | return xrealloc (pa, nbytes); |
| 883 | } | 883 | } |
| @@ -924,13 +924,13 @@ xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min, | |||
| 924 | NITEMS_MAX, and what the C language can represent safely. */ | 924 | NITEMS_MAX, and what the C language can represent safely. */ |
| 925 | 925 | ||
| 926 | ptrdiff_t n, nbytes; | 926 | ptrdiff_t n, nbytes; |
| 927 | if (INT_ADD_WRAPV (n0, n0 >> 1, &n)) | 927 | if (ckd_add (&n, n0, n0 >> 1)) |
| 928 | n = PTRDIFF_MAX; | 928 | n = PTRDIFF_MAX; |
| 929 | if (0 <= nitems_max && nitems_max < n) | 929 | if (0 <= nitems_max && nitems_max < n) |
| 930 | n = nitems_max; | 930 | n = nitems_max; |
| 931 | 931 | ||
| 932 | ptrdiff_t adjusted_nbytes | 932 | ptrdiff_t adjusted_nbytes |
| 933 | = ((INT_MULTIPLY_WRAPV (n, item_size, &nbytes) || SIZE_MAX < nbytes) | 933 | = ((ckd_mul (&nbytes, n, item_size) || SIZE_MAX < nbytes) |
| 934 | ? min (PTRDIFF_MAX, SIZE_MAX) | 934 | ? min (PTRDIFF_MAX, SIZE_MAX) |
| 935 | : nbytes < DEFAULT_MXFAST ? DEFAULT_MXFAST : 0); | 935 | : nbytes < DEFAULT_MXFAST ? DEFAULT_MXFAST : 0); |
| 936 | if (adjusted_nbytes) | 936 | if (adjusted_nbytes) |
| @@ -942,9 +942,9 @@ xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min, | |||
| 942 | if (! pa) | 942 | if (! pa) |
| 943 | *nitems = 0; | 943 | *nitems = 0; |
| 944 | if (n - n0 < nitems_incr_min | 944 | if (n - n0 < nitems_incr_min |
| 945 | && (INT_ADD_WRAPV (n0, nitems_incr_min, &n) | 945 | && (ckd_add (&n, n0, nitems_incr_min) |
| 946 | || (0 <= nitems_max && nitems_max < n) | 946 | || (0 <= nitems_max && nitems_max < n) |
| 947 | || INT_MULTIPLY_WRAPV (n, item_size, &nbytes))) | 947 | || ckd_mul (&nbytes, n, item_size))) |
| 948 | memory_full (SIZE_MAX); | 948 | memory_full (SIZE_MAX); |
| 949 | pa = xrealloc (pa, nbytes); | 949 | pa = xrealloc (pa, nbytes); |
| 950 | *nitems = n; | 950 | *nitems = n; |
| @@ -2375,7 +2375,7 @@ a multibyte string even if INIT is an ASCII character. */) | |||
| 2375 | ptrdiff_t len = CHAR_STRING (c, str); | 2375 | ptrdiff_t len = CHAR_STRING (c, str); |
| 2376 | EMACS_INT string_len = XFIXNUM (length); | 2376 | EMACS_INT string_len = XFIXNUM (length); |
| 2377 | 2377 | ||
| 2378 | if (INT_MULTIPLY_WRAPV (len, string_len, &nbytes)) | 2378 | if (ckd_mul (&nbytes, len, string_len)) |
| 2379 | string_overflow (); | 2379 | string_overflow (); |
| 2380 | val = make_clear_multibyte_string (string_len, nbytes, clearit); | 2380 | val = make_clear_multibyte_string (string_len, nbytes, clearit); |
| 2381 | if (!clearit) | 2381 | if (!clearit) |
| @@ -5226,7 +5226,7 @@ mark_memory (void const *start, void const *end) | |||
| 5226 | a Lisp_Object might be split into registers saved into | 5226 | a Lisp_Object might be split into registers saved into |
| 5227 | non-adjacent words and P might be the low-order word's value. */ | 5227 | non-adjacent words and P might be the low-order word's value. */ |
| 5228 | intptr_t ip; | 5228 | intptr_t ip; |
| 5229 | INT_ADD_WRAPV ((intptr_t) p, (intptr_t) lispsym, &ip); | 5229 | ckd_add (&ip, (intptr_t) p, (intptr_t) lispsym); |
| 5230 | mark_maybe_pointer ((void *) ip, true); | 5230 | mark_maybe_pointer ((void *) ip, true); |
| 5231 | } | 5231 | } |
| 5232 | } | 5232 | } |