Commit ceeb3d7d authored by Eli Zaretskii's avatar Eli Zaretskii

(align): If the argument SIZE would overflow

__malloc_ptrdiff_t, fail right away.
parent 9f9a5e7a
2001-04-09 Eli Zaretskii <eliz@is.elta.co.il>
* gmalloc.c (align): If the argument SIZE would overflow
__malloc_ptrdiff_t, fail right away.
2001-04-06 Gerd Moellmann <gerd@gnu.org>
* xfns.c (compute_tip_xy): Add parameters WIDTH and HEIGHT.
......
......@@ -437,7 +437,14 @@ align (size)
__ptr_t result;
unsigned long int adj;
result = (*__morecore) (size);
/* align accepts an unsigned argument, but __morecore accepts a
signed one. This could lead to trouble if SIZE overflows a
signed int type accepted by __morecore. We just punt in that
case, since they are requesting a ludicrous amount anyway. */
if ((__malloc_ptrdiff_t)size < 0)
result = 0;
else
result = (*__morecore) (size);
adj = (unsigned long int) ((unsigned long int) ((char *) result -
(char *) NULL)) % BLOCKSIZE;
if (adj != 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment