When allocating a buffer failed, don't fail silently.
This commit is contained in:
parent
f3efbb406a
commit
b4780b53b4
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: cat.c,v 1.13 1997/04/27 18:34:33 kleink Exp $ */
|
/* $NetBSD: cat.c,v 1.14 1997/06/26 23:07:19 kleink Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1989, 1993
|
* Copyright (c) 1989, 1993
|
||||||
@ -46,7 +46,7 @@ static char copyright[] =
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
|
static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: cat.c,v 1.13 1997/04/27 18:34:33 kleink Exp $";
|
static char rcsid[] = "$NetBSD: cat.c,v 1.14 1997/06/26 23:07:19 kleink Exp $";
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ raw_cat(rfd)
|
|||||||
err(1, "%s", filename);
|
err(1, "%s", filename);
|
||||||
bsize = MAX(sbuf.st_blksize, 1024);
|
bsize = MAX(sbuf.st_blksize, 1024);
|
||||||
if ((buf = malloc((u_int)bsize)) == NULL)
|
if ((buf = malloc((u_int)bsize)) == NULL)
|
||||||
err(1, NULL);
|
err(1, "cannot allocate buffer");
|
||||||
}
|
}
|
||||||
while ((nr = read(rfd, buf, bsize)) > 0)
|
while ((nr = read(rfd, buf, bsize)) > 0)
|
||||||
for (off = 0; nr; nr -= nw, off += nw)
|
for (off = 0; nr; nr -= nw, off += nw)
|
||||||
|
Loading…
Reference in New Issue
Block a user