diff options
Diffstat (limited to 'crypto/heimdal/appl/rcp/util.c')
-rw-r--r-- | crypto/heimdal/appl/rcp/util.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/heimdal/appl/rcp/util.c b/crypto/heimdal/appl/rcp/util.c index 9d0f6d5..3621d30 100644 --- a/crypto/heimdal/appl/rcp/util.c +++ b/crypto/heimdal/appl/rcp/util.c @@ -43,7 +43,7 @@ static const char rcsid[] = #include "rcp_locl.h" -RCSID("$Id: util.c,v 1.5 2001/01/29 23:36:37 assar Exp $"); +RCSID("$Id: util.c,v 1.6 2001/09/04 14:35:58 assar Exp $"); char * colon(cp) @@ -136,6 +136,7 @@ allocbuf(bp, fd, blksize) { struct stat stb; size_t size; + char *p; if (fstat(fd, &stb) < 0) { run_err("fstat: %s", strerror(errno)); @@ -146,11 +147,16 @@ allocbuf(bp, fd, blksize) size = blksize; if (bp->cnt >= size) return (bp); - if ((bp->buf = realloc(bp->buf, size)) == NULL) { + if ((p = realloc(bp->buf, size)) == NULL) { + if (bp->buf) + free(bp->buf); + bp->buf = NULL; bp->cnt = 0; run_err("%s", strerror(errno)); return (0); } + memset(p, 0, size); + bp->buf = p; bp->cnt = size; return (bp); } |