mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
(__argp_fmtstream_ensure): Check for size_t overflow when reallocating storage.
This commit is contained in:
@ -385,10 +385,11 @@ __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
|
|||||||
if ((size_t) (fs->end - fs->buf) < amount)
|
if ((size_t) (fs->end - fs->buf) < amount)
|
||||||
/* Gotta grow the buffer. */
|
/* Gotta grow the buffer. */
|
||||||
{
|
{
|
||||||
size_t new_size = fs->end - fs->buf + amount;
|
size_t old_size = fs->end - fs->buf;
|
||||||
char *new_buf = realloc (fs->buf, new_size);
|
size_t new_size = old_size + amount;
|
||||||
|
char *new_buf;
|
||||||
|
|
||||||
if (! new_buf)
|
if (new_size < old_size || ! (new_buf = realloc (fs->buf, new_size)))
|
||||||
{
|
{
|
||||||
__set_errno (ENOMEM);
|
__set_errno (ENOMEM);
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user