-/* $OpenBSD: fsck.c,v 1.36 2015/05/29 15:53:46 deraadt Exp $ */
+/* $OpenBSD: fsck.c,v 1.37 2015/05/29 15:57:36 deraadt Exp $ */
/* $NetBSD: fsck.c,v 1.7 1996/10/03 20:06:30 christos Exp $ */
/*
switch (pid = fork()) {
case -1: /* Error. */
warn("fork");
- if (optbuf)
- free(optbuf);
+ free(optbuf);
free(argv);
return (1);
/* NOTREACHED */
default: /* Parent. */
- if (optbuf)
- free(optbuf);
+ free(optbuf);
free(argv);
if (pidp) {
} else
cp = estrdup(s1);
- if (s0 && fr)
+ if (fr)
free(s0);
return (cp);
}
-/* $OpenBSD: fsutil.c,v 1.20 2015/01/16 06:39:57 deraadt Exp $ */
+/* $OpenBSD: fsutil.c,v 1.21 2015/05/29 15:57:36 deraadt Exp $ */
/* $NetBSD: fsutil.c,v 1.2 1996/10/03 20:06:31 christos Exp $ */
/*
{
void *newp;
- if (s == 0)
+ if (n == 0 || s == 0) {
+ free(p);
err(1, "realloc failed");
+ }
newp = reallocarray(p, n, s);
if (newp == NULL) {
- if (p)
- free(p);
+ free(p);
err(1, "realloc failed");
}
return newp;