diff options
author | Omar Polo <op@omarpolo.com> | 2022-04-08 13:44:49 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2022-04-08 13:44:49 +0000 |
commit | d8d170aa5ee1498babee095078b3888f1525a2b3 (patch) | |
tree | 7b025561608a276e18b63bf6955bb34a2d948fac /parse.y | |
parent | aa6b8cf8ac4d93444bc2b4076b98621968bfc6ab (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.y | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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 |