diff options
Diffstat (limited to 'src/gmalloc.c')
| -rw-r--r-- | src/gmalloc.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gmalloc.c b/src/gmalloc.c index 751e90baf13..3508304da33 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c | |||
| @@ -437,7 +437,14 @@ align (size) | |||
| 437 | __ptr_t result; | 437 | __ptr_t result; |
| 438 | unsigned long int adj; | 438 | unsigned long int adj; |
| 439 | 439 | ||
| 440 | result = (*__morecore) (size); | 440 | /* align accepts an unsigned argument, but __morecore accepts a |
| 441 | signed one. This could lead to trouble if SIZE overflows a | ||
| 442 | signed int type accepted by __morecore. We just punt in that | ||
| 443 | case, since they are requesting a ludicrous amount anyway. */ | ||
| 444 | if ((__malloc_ptrdiff_t)size < 0) | ||
| 445 | result = 0; | ||
| 446 | else | ||
| 447 | result = (*__morecore) (size); | ||
| 441 | adj = (unsigned long int) ((unsigned long int) ((char *) result - | 448 | adj = (unsigned long int) ((unsigned long int) ((char *) result - |
| 442 | (char *) NULL)) % BLOCKSIZE; | 449 | (char *) NULL)) % BLOCKSIZE; |
| 443 | if (adj != 0) | 450 | if (adj != 0) |