Commit Diff
Diff:
2025e96d976677a7bf6bbe54185eb7bca026fe9d
edc5ca667dbaf67ff39676341a131ced7502a36d
Commit:
edc5ca667dbaf67ff39676341a131ced7502a36d
Tree:
3206cc5a4b2d2a28b1808eebbf64f67f96c0a3a9
Author:
Omar Polo <op@omarpolo.com>
Date:
Sat Sep 10 10:12:37 2022 UTC
Message:
properly initialize the TAILQs at vhost creation
commit - 2025e96d976677a7bf6bbe54185eb7bca026fe9d
commit + edc5ca667dbaf67ff39676341a131ced7502a36d
blob - 655192b07233e928be3a7d0ceb23caa01a2a40de
blob + 01df20f95a8e0bcc256fc7fcded173c6aaee5f86
--- parse.y
+++ parse.y
@@ -267,10 +267,7 @@ servopt : ALIAS string {
a = xcalloc(1, sizeof(*a));
a->alias = $2;
- if (TAILQ_EMPTY(&host->aliases))
- TAILQ_INSERT_HEAD(&host->aliases, a, aliases);
- else
- TAILQ_INSERT_TAIL(&host->aliases, a, aliases);
+ TAILQ_INSERT_TAIL(&host->aliases, a, aliases);
}
| CERT string {
only_once(host->cert, "cert");
@@ -1025,7 +1022,14 @@ new_vhost(void)
struct vhost *
new_vhost(void)
{
- return xcalloc(1, sizeof(struct vhost));
+ struct vhost *h;
+
+ h = xcalloc(1, sizeof(*h));
+ TAILQ_INIT(&h->locations);
+ TAILQ_INIT(&h->params);
+ TAILQ_INIT(&h->aliases);
+ TAILQ_INIT(&h->proxies);
+ return h;
}
struct location *
@@ -1205,8 +1209,5 @@ add_param(char *name, char *val)
e = xcalloc(1, sizeof(*e));
e->name = name;
e->value = val;
- if (TAILQ_EMPTY(h))
- TAILQ_INSERT_HEAD(h, e, envs);
- else
- TAILQ_INSERT_TAIL(h, e, envs);
+ TAILQ_INSERT_TAIL(h, e, envs);
}
Omar Polo