aboutsummaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2022-04-08 13:44:49 +0000
committerOmar Polo <op@omarpolo.com>2022-04-08 13:44:49 +0000
commitd8d170aa5ee1498babee095078b3888f1525a2b3 (patch)
tree7b025561608a276e18b63bf6955bb34a2d948fac /parse.y
parentaa6b8cf8ac4d93444bc2b4076b98621968bfc6ab (diff)
allow add_mime to fail
add_mime nows allocate dinamically copies of the passed strings, so that we can actually free what we parse from the config file. This matters a lot especially with lengthy `types' block: strings that reach the internal mapping are never free'd, so every manual addition is leaked.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y11
1 files changed, 8 insertions, 3 deletions
diff --git a/parse.y b/parse.y
index d28195a..ed14810 100644
--- a/parse.y
+++ b/parse.y
@@ -219,13 +219,15 @@ option : CHROOT string { conf.chroot = $2; }
yywarn("`mime MIME EXT' is deprecated and will be "
"removed in a future version, please use the new "
"`types' block.");
- add_mime(&conf.mime, $2, $3);
+ if (add_mime(&conf.mime, $2, $3) == -1)
+ err(1, "add_mime");
}
| MAP string TOEXT string {
yywarn("`map mime to-ext' is deprecated and will be "
"removed in a future version, please use the new "
"`types' block.");
- add_mime(&conf.mime, $2, $4);
+ if (add_mime(&conf.mime, $2, $4) == -1)
+ err(1, "add_mime");
}
| PORT NUM { conf.port = check_port_num($2); }
| PREFORK NUM { conf.prefork = check_prefork_num($2); }
@@ -488,7 +490,10 @@ medianames_l : medianames_l medianamesl
| medianamesl
;
-medianamesl : numberstring { add_mime(&conf.mime, current_media, $1); }
+medianamesl : numberstring {
+ if (add_mime(&conf.mime, current_media, $1) == -1)
+ err(1, "add_mime");
+ }
;
nl : '\n' optnl