Use the right size for several calloc calls.

When allocating for a Char **, it should use sizeof(Char *), not
sizeof(Char **). This doesn't actually affect the results except
on DS9000 though :-)
This commit is contained in:
dholland 2020-08-09 00:34:21 +00:00
parent 85bd10cb24
commit 7f63690a47
3 changed files with 12 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.34 2020/08/09 00:22:53 dholland Exp $ */
/* $NetBSD: dir.c,v 1.35 2020/08/09 00:34:21 dholland Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: dir.c,v 1.34 2020/08/09 00:22:53 dholland Exp $");
__RCSID("$NetBSD: dir.c,v 1.35 2020/08/09 00:34:21 dholland Exp $");
#endif
#endif /* not lint */
@ -147,7 +147,7 @@ dset(Char *dp)
* other junk characters glob will fail.
*/
vec = xmalloc((size_t)(2 * sizeof(Char **)));
vec = xmalloc(2 * sizeof(*vec));
vec[0] = Strsave(dp);
vec[1] = 0;
setq(STRcwd, vec, &shvhed);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lex.c,v 1.35 2020/08/09 00:22:53 dholland Exp $ */
/* $NetBSD: lex.c,v 1.36 2020/08/09 00:34:21 dholland Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: lex.c,v 1.35 2020/08/09 00:22:53 dholland Exp $");
__RCSID("$NetBSD: lex.c,v 1.36 2020/08/09 00:34:21 dholland Exp $");
#endif
#endif /* not lint */
@ -1453,7 +1453,8 @@ again:
if (buf >= fblocks) {
Char **nfbuf;
nfbuf = xcalloc((size_t) (fblocks + 2), sizeof(char **));
/* XXX the cast is needed because fblocks is signed */
nfbuf = xcalloc((size_t)(fblocks + 2), sizeof(*nfbuf));
if (fbuf) {
(void)blkcpy(nfbuf, fbuf);
free(fbuf);
@ -1623,7 +1624,7 @@ settell(void)
return;
if (lseek(SHIN, (off_t) 0, SEEK_CUR) < 0 || errno == ESPIPE)
return;
fbuf = xcalloc(2, sizeof(Char **));
fbuf = xcalloc(2, sizeof(*fbuf));
fblocks = 1;
fbuf[0] = xcalloc(BUFSIZE, sizeof(Char));
fseekp = fbobp = feobp = lseek(SHIN, (off_t) 0, SEEK_CUR);

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.20 2020/08/09 00:22:53 dholland Exp $ */
/* $NetBSD: parse.c,v 1.21 2020/08/09 00:34:21 dholland Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: parse.c,v 1.20 2020/08/09 00:22:53 dholland Exp $");
__RCSID("$NetBSD: parse.c,v 1.21 2020/08/09 00:34:21 dholland Exp $");
#endif
#endif /* not lint */
@ -509,7 +509,8 @@ again:
if (n < 0)
n = 0;
t = xcalloc(1, sizeof(*t));
av = xcalloc((size_t)(n + 1), sizeof(Char **));
/* XXX the cast is needed because n is signed */
av = xcalloc((size_t)(n + 1), sizeof(*av));
t->t_dcom = av;
n = 0;
if (p2->word[0] == ')')