X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fargp-fmtstream.c;h=c88c3db2147136dbb8931f0b50dc1953b050b940;hb=55da53d0db0c7a9fd82b2abc809560b3089df6a5;hp=d06ea8453bc1df2c163c2cebb9b857af98f8d354;hpb=46e647a11e9d46474f478faade784c8fee57d148;p=gnulib.git diff --git a/lib/argp-fmtstream.c b/lib/argp-fmtstream.c index d06ea8453..c88c3db21 100644 --- a/lib/argp-fmtstream.c +++ b/lib/argp-fmtstream.c @@ -3,20 +3,19 @@ This file is part of the GNU C Library. Written by Miles Bader . - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. - The GNU C Library is distributed in the hope that it will be useful, + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This package emulates glibc `line_wrap_stream' semantics for systems that don't have that. */ @@ -385,10 +384,11 @@ __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount) if ((size_t) (fs->end - fs->buf) < amount) /* Gotta grow the buffer. */ { - size_t new_size = fs->end - fs->buf + amount; - char *new_buf = realloc (fs->buf, new_size); + size_t old_size = fs->end - fs->buf; + 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); return 0;