aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 90a10ec2a34..93f739c0d4b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2933,8 +2933,8 @@ struct sortstr
2933struct sortstrlist 2933struct sortstrlist
2934{ 2934{
2935 struct sortstr *buf; /* An array that expands as needed; never freed. */ 2935 struct sortstr *buf; /* An array that expands as needed; never freed. */
2936 int size; /* Allocated length of that array. */ 2936 ptrdiff_t size; /* Allocated length of that array. */
2937 int used; /* How much of the array is currently in use. */ 2937 ptrdiff_t used; /* How much of the array is currently in use. */
2938 EMACS_INT bytes; /* Total length of the strings in buf. */ 2938 EMACS_INT bytes; /* Total length of the strings in buf. */
2939}; 2939};
2940 2940
@@ -2969,7 +2969,10 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str,
2969 2969
2970 if (ssl->used == ssl->size) 2970 if (ssl->used == ssl->size)
2971 { 2971 {
2972 if (ssl->buf) 2972 if (min (PTRDIFF_MAX, SIZE_MAX) / (sizeof (struct sortstr) * 2)
2973 < ssl->size)
2974 memory_full (SIZE_MAX);
2975 else if (0 < ssl->size)
2973 ssl->size *= 2; 2976 ssl->size *= 2;
2974 else 2977 else
2975 ssl->size = 5; 2978 ssl->size = 5;