diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2021-04-01 00:59:54 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2021-04-01 01:04:45 -0700 |
commit | 152be6db1b016ed2a510ddc3895a937b21fbd538 (patch) | |
tree | b35eea45ff5162ab6007046287511bb32033df4d /lib | |
parent | e54b645fc6b8422562327443bda575c65d931fbd (diff) | |
download | gnulib-152be6db1b016ed2a510ddc3895a937b21fbd538.tar.gz |
xalloc: delay setting size until success
* lib/xalloc.h (x2nrealloc): Don’t change *PN until after xrealloc
succeeds, in case xalloc_die or one of its callees or longjmp
targets uses *PN. Similar code in xpalloc already does this.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/xalloc.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/xalloc.h b/lib/xalloc.h index 76d83c63c1..5633fdf3c4 100644 --- a/lib/xalloc.h +++ b/lib/xalloc.h @@ -206,8 +206,9 @@ x2nrealloc (void *p, size_t *pn, size_t s) n += n / 2 + 1; } + p = xrealloc (p, n * s); *pn = n; - return xrealloc (p, n * s); + return p; } /* Return a pointer to a new buffer of N bytes. This is like xmalloc, |