Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/cache_cf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4512,20 +4512,19 @@ static void parse_HeaderWithAclList(HeaderWithAclList **headers)
if (hwa.fieldId == Http::HdrType::BAD_HDR)
hwa.fieldId = Http::HdrType::OTHER;

Format::Format *nlf = new ::Format::Format("hdrWithAcl");
ConfigParser::EnableMacros();
String buf = ConfigParser::NextQuotedToken();
const auto fieldValue = ConfigParser::NextQuotedToken();
ConfigParser::DisableMacros();
hwa.fieldValue = buf.termedBuf();
if (!fieldValue)
throw TextException("missing a required field-value parameter", Here());
hwa.fieldValue = fieldValue;
hwa.quoted = ConfigParser::LastTokenWasQuoted();
if (hwa.quoted) {
if (!nlf->parse(hwa.fieldValue.c_str())) {
self_destruct();
return;
}
hwa.valueFormat = nlf;
} else
delete nlf;
// XXX: We leak memory when parse() throws due to a parsing failure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This memory leak is an old out-of-scope bug. This PR does not make it worse.

hwa.valueFormat = new ::Format::Format("hdrWithAcl");
const auto parsed = hwa.valueFormat->parse(hwa.fieldValue.c_str());
Assure(parsed); // parse() never returns false for a freshly created hwa.valueFormat
}
aclParseAclList(LegacyParser, &hwa.aclList, (hwa.fieldName + ':' + hwa.fieldValue).c_str());
(*headers)->push_back(hwa);
}
Expand Down
Loading