aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2019-08-12 17:39:09 +0300
committerEli Zaretskii2019-08-12 17:39:09 +0300
commit2b329ed420eb15f6738edd402697ac2876b2aa61 (patch)
treee0f0a19c6c32e7733f8300ecd4522c1c5ada59eb /src
parentdbae38efc22e117c20f6cd9bfd8300d692055c70 (diff)
downloademacs-2b329ed420eb15f6738edd402697ac2876b2aa61.tar.gz
emacs-2b329ed420eb15f6738edd402697ac2876b2aa61.zip
; Add commentary to recent changes
* src/image.c (png_load_body): * src/editfns.c (styled_format): * src/casefiddle.c (do_casify_multibyte_string): * src/alloc.c (free_cons): Comment why we use a signed temporary integer variable. (Bug#37006)
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c2
-rw-r--r--src/casefiddle.c2
-rw-r--r--src/editfns.c4
-rw-r--r--src/image.c4
4 files changed, 10 insertions, 2 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 8227feadae5..39833f8decb 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2542,6 +2542,8 @@ free_cons (struct Lisp_Cons *ptr)
2542 ptr->u.s.u.chain = cons_free_list; 2542 ptr->u.s.u.chain = cons_free_list;
2543 ptr->u.s.car = dead_object (); 2543 ptr->u.s.car = dead_object ();
2544 cons_free_list = ptr; 2544 cons_free_list = ptr;
2545 /* Use a temporary signed variable, since otherwise INT_ADD_WRAPV
2546 might incorrectly return non-zero. */
2545 int incr = sizeof *ptr; 2547 int incr = sizeof *ptr;
2546 if (INT_ADD_WRAPV (consing_until_gc, incr, &consing_until_gc)) 2548 if (INT_ADD_WRAPV (consing_until_gc, incr, &consing_until_gc))
2547 consing_until_gc = OBJECT_CT_MAX; 2549 consing_until_gc = OBJECT_CT_MAX;
diff --git a/src/casefiddle.c b/src/casefiddle.c
index 6fcb5852141..741973e40af 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -265,6 +265,8 @@ do_casify_multibyte_string (struct casing_context *ctx, Lisp_Object obj)
265 265
266 ptrdiff_t size = SCHARS (obj), n; 266 ptrdiff_t size = SCHARS (obj), n;
267 USE_SAFE_ALLOCA; 267 USE_SAFE_ALLOCA;
268 /* Use a temporary signed variable, since otherwise INT_ADD_WRAPV
269 might incorrectly return non-zero. */
268 ptrdiff_t casing_str_buf_size = sizeof (struct casing_str_buf); 270 ptrdiff_t casing_str_buf_size = sizeof (struct casing_str_buf);
269 if (INT_MULTIPLY_WRAPV (size, MAX_MULTIBYTE_LENGTH, &n) 271 if (INT_MULTIPLY_WRAPV (size, MAX_MULTIBYTE_LENGTH, &n)
270 || INT_ADD_WRAPV (n, casing_str_buf_size, &n)) 272 || INT_ADD_WRAPV (n, casing_str_buf_size, &n))
diff --git a/src/editfns.c b/src/editfns.c
index 25f80bedb1c..19bbfdcd478 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3158,12 +3158,14 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
3158 /* Upper bound on number of format specs. Each uses at least 2 chars. */ 3158 /* Upper bound on number of format specs. Each uses at least 2 chars. */
3159 ptrdiff_t nspec_bound = SCHARS (args[0]) >> 1; 3159 ptrdiff_t nspec_bound = SCHARS (args[0]) >> 1;
3160 3160
3161 /* Allocate the info and discarded tables. */ 3161 /* Use a temporary signed variable, since otherwise INT_ADD_WRAPV
3162 might incorrectly return non-zero. */
3162 ptrdiff_t info_size = sizeof *info, alloca_size; 3163 ptrdiff_t info_size = sizeof *info, alloca_size;
3163 if (INT_MULTIPLY_WRAPV (nspec_bound, info_size, &info_size) 3164 if (INT_MULTIPLY_WRAPV (nspec_bound, info_size, &info_size)
3164 || INT_ADD_WRAPV (formatlen, info_size, &alloca_size) 3165 || INT_ADD_WRAPV (formatlen, info_size, &alloca_size)
3165 || SIZE_MAX < alloca_size) 3166 || SIZE_MAX < alloca_size)
3166 memory_full (SIZE_MAX); 3167 memory_full (SIZE_MAX);
3168 /* Allocate the info and discarded tables. */
3167 info = SAFE_ALLOCA (alloca_size); 3169 info = SAFE_ALLOCA (alloca_size);
3168 /* discarded[I] is 1 if byte I of the format 3170 /* discarded[I] is 1 if byte I of the format
3169 string was not copied into the output. 3171 string was not copied into the output.
diff --git a/src/image.c b/src/image.c
index a59be0cd8ff..b37851f0963 100644
--- a/src/image.c
+++ b/src/image.c
@@ -6658,11 +6658,13 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
6658 /* Number of bytes needed for one row of the image. */ 6658 /* Number of bytes needed for one row of the image. */
6659 row_bytes = png_get_rowbytes (png_ptr, info_ptr); 6659 row_bytes = png_get_rowbytes (png_ptr, info_ptr);
6660 6660
6661 /* Allocate memory for the image. */ 6661 /* Use a temporary signed variable, since otherwise
6662 INT_MULTIPLY_WRAPV might incorrectly return non-zero. */
6662 ptrdiff_t nbytes = sizeof *pixels; 6663 ptrdiff_t nbytes = sizeof *pixels;
6663 if (INT_MULTIPLY_WRAPV (row_bytes, nbytes, &nbytes) 6664 if (INT_MULTIPLY_WRAPV (row_bytes, nbytes, &nbytes)
6664 || INT_MULTIPLY_WRAPV (nbytes, height, &nbytes)) 6665 || INT_MULTIPLY_WRAPV (nbytes, height, &nbytes))
6665 memory_full (SIZE_MAX); 6666 memory_full (SIZE_MAX);
6667 /* Allocate memory for the image. */
6666 c->pixels = pixels = xmalloc (nbytes); 6668 c->pixels = pixels = xmalloc (nbytes);
6667 c->rows = rows = xmalloc (height * sizeof *rows); 6669 c->rows = rows = xmalloc (height * sizeof *rows);
6668 for (i = 0; i < height; ++i) 6670 for (i = 0; i < height; ++i)