ref: a312efcf46527321f1a87033214c752a6bdda62e
parent: 7f6552d4e83fdb7ad2f27df890459261d1a45492
author: Roberto E. Vargas Caballero <[email protected]>
date: Sun Jan 19 10:47:30 EST 2020
libmach: Rework of newmap() Small whitespaces and variable reduction.
--- a/src/libmach/newmap.c
+++ b/src/libmach/newmap.c
@@ -11,19 +11,18 @@
Map *
newmap(int n, FILE *fp)
{
- size_t siz, vsiz;
+ size_t vsiz;
struct mapsec *p;
Map *map;
- siz = sizeof(*map);
if (n > SIZE_MAX/sizeof(struct mapsec))
goto out_range;
-
vsiz = n * sizeof(struct mapsec);
- if (vsiz > SIZE_MAX - siz)
+ if (vsiz > SIZE_MAX - sizeof(*map))
goto out_range;
+ vsiz += sizeof(*map);
- if ((map = malloc(siz + vsiz)) == NULL)
+ if ((map = malloc(vsiz)) == NULL)
return NULL;
map->n = n;
@@ -34,6 +33,6 @@
return map;
out_range:
- errno = ERANGE;
- return NULL;
+ errno = ERANGE;
+ return NULL;
}