]> git.eshelyaron.com Git - emacs.git/commitdiff
; Add commentary to recent changes
authorEli Zaretskii <eliz@gnu.org>
Mon, 12 Aug 2019 14:39:09 +0000 (17:39 +0300)
committerEli Zaretskii <eliz@gnu.org>
Mon, 12 Aug 2019 14:39:09 +0000 (17:39 +0300)
* 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)

src/alloc.c
src/casefiddle.c
src/editfns.c
src/image.c

index 8227feadae5155cd6f9d5ff6782a88eb8dfb8572..39833f8decb51b0f6dbf9a0f59e50cdabb64d062 100644 (file)
@@ -2542,6 +2542,8 @@ free_cons (struct Lisp_Cons *ptr)
   ptr->u.s.u.chain = cons_free_list;
   ptr->u.s.car = dead_object ();
   cons_free_list = ptr;
+  /* Use a temporary signed variable, since otherwise INT_ADD_WRAPV
+     might incorrectly return non-zero.  */
   int incr = sizeof *ptr;
   if (INT_ADD_WRAPV (consing_until_gc, incr, &consing_until_gc))
     consing_until_gc = OBJECT_CT_MAX;
index 6fcb5852141b173f4ecba13ef6a648a97d09ff26..741973e40aff2f6e01a02e05f97e06672b6df3ef 100644 (file)
@@ -265,6 +265,8 @@ do_casify_multibyte_string (struct casing_context *ctx, Lisp_Object obj)
 
   ptrdiff_t size = SCHARS (obj), n;
   USE_SAFE_ALLOCA;
+  /* Use a temporary signed variable, since otherwise INT_ADD_WRAPV
+     might incorrectly return non-zero.  */
   ptrdiff_t casing_str_buf_size = sizeof (struct casing_str_buf);
   if (INT_MULTIPLY_WRAPV (size, MAX_MULTIBYTE_LENGTH, &n)
       || INT_ADD_WRAPV (n, casing_str_buf_size, &n))
index 25f80bedb1cc613f592a278e8ad806eb29688a1a..19bbfdcd478e43ef62d8d3506960cd3e9f9730aa 100644 (file)
@@ -3158,12 +3158,14 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
   /* Upper bound on number of format specs.  Each uses at least 2 chars.  */
   ptrdiff_t nspec_bound = SCHARS (args[0]) >> 1;
 
-  /* Allocate the info and discarded tables.  */
+  /* Use a temporary signed variable, since otherwise INT_ADD_WRAPV
+     might incorrectly return non-zero.  */
   ptrdiff_t info_size = sizeof *info, alloca_size;
   if (INT_MULTIPLY_WRAPV (nspec_bound, info_size, &info_size)
       || INT_ADD_WRAPV (formatlen, info_size, &alloca_size)
       || SIZE_MAX < alloca_size)
     memory_full (SIZE_MAX);
+  /* Allocate the info and discarded tables.  */
   info = SAFE_ALLOCA (alloca_size);
   /* discarded[I] is 1 if byte I of the format
      string was not copied into the output.
index a59be0cd8ff5b41c50f7cdbafa34fc8da756f7f8..b37851f0963849b2f568dcb27b392644587b980d 100644 (file)
@@ -6658,11 +6658,13 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
   /* Number of bytes needed for one row of the image.  */
   row_bytes = png_get_rowbytes (png_ptr, info_ptr);
 
-  /* Allocate memory for the image.  */
+  /* Use a temporary signed variable, since otherwise
+     INT_MULTIPLY_WRAPV might incorrectly return non-zero.  */
   ptrdiff_t nbytes = sizeof *pixels;
   if (INT_MULTIPLY_WRAPV (row_bytes, nbytes, &nbytes)
       || INT_MULTIPLY_WRAPV (nbytes, height, &nbytes))
     memory_full (SIZE_MAX);
+  /* Allocate memory for the image.  */
   c->pixels = pixels = xmalloc (nbytes);
   c->rows = rows = xmalloc (height * sizeof *rows);
   for (i = 0; i < height; ++i)