Hello tech@
adjust error logic for zero sized allocations and the error messages for
the recent erealloc to ereallocarray switch.
A follow up diff will clean up all "if (x) free(x);" statements.
Index: fsutil.c
===================================================================
RCS file: /cvs/src/sbin/fsck/fsutil.c,v
retrieving revision 1.20
diff -u -p -r1.20 fsutil.c
--- fsutil.c 16 Jan 2015 06:39:57 -0000 1.20
+++ fsutil.c 29 May 2015 08:48:57 -0000
@@ -252,13 +252,15 @@ ereallocarray(void *p, size_t n, size_t
{
void *newp;
- if (s == 0)
- err(1, "realloc failed");
+ if (n == 0 || s == 0) {
+ free(p);
+ err(1, "reallocarray failed");
+ }
newp = reallocarray(p, n, s);
if (newp == NULL) {
if (p)
free(p);
- err(1, "realloc failed");
+ err(1, "reallocarray failed");
}
return newp;
}