fix segfault on parsing of -v and -m - quark - quark web server | |
git clone git://git.suckless.org/quark | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 69bb7710eb9bcc73dd0836b9b88228259c9586d3 | |
parent 6770dc06e69f422124d1e9c0efdefa7cc4e98b61 | |
Author: Josuah Demangeon <[email protected]> | |
Date: Mon, 2 Apr 2018 02:54:59 +0200 | |
fix segfault on parsing of -v and -m | |
The length is initially 0 so it needs to be incremented before | |
reallocarray to avoid ...alloc(0); and keep some space for the element | |
to insert. | |
Diffstat: | |
M main.c | 4 ++-- | |
1 file changed, 2 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/main.c b/main.c | |
@@ -166,7 +166,7 @@ main(int argc, char *argv[]) | |
if (!(tok = strdup(EARGF(usage())))) { | |
die("strdup:"); | |
} | |
- if (!(s.vhost = reallocarray(s.vhost, s.vhost_len++, | |
+ if (!(s.vhost = reallocarray(s.vhost, ++s.vhost_len, | |
sizeof(struct vhost)))) { | |
die("reallocarray:"); | |
} | |
@@ -182,7 +182,7 @@ main(int argc, char *argv[]) | |
if (!(tok = strdup(EARGF(usage())))) { | |
die("strdup:"); | |
} | |
- if (!(s.map = reallocarray(s.map, s.map_len++, | |
+ if (!(s.map = reallocarray(s.map, ++s.map_len, | |
sizeof(struct map)))) { | |
die("reallocarray:"); | |
} |