Skip to content

Commit ddabeab

Browse files
committed
DPL: do not use an attribute value the query parser failed to read
When the value of a query attribute was empty, e.g. "x:TST/A1/0?lifetime=", assignLastStringMatch pushed the error state and returned without setting currentValue, but IN_END_VALUE went on to read *currentValue, which was unset. The DataQuery test crashed on this with GCC 15. Stop at the error, merge the three identical branches, and reset the attribute key and value for each ;-separated query like the rest of the per-query state.
1 parent 5dffc90 commit ddabeab

1 file changed

Lines changed: 19 additions & 32 deletions

File tree

‎Framework/Core/src/DataDescriptorQueryBuilder.cxx‎

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ std::vector<InputSpec> DataDescriptorQueryBuilder::parse(char const* config)
207207
currentDescription.reset();
208208
currentSubSpec.reset();
209209
currentTimeModulo.reset();
210+
currentKey.reset();
211+
currentValue.reset();
210212
pushState(IN_BEGIN_BINDING);
211213
} break;
212214
case IN_BEGIN_BINDING: {
@@ -322,41 +324,26 @@ std::vector<InputSpec> DataDescriptorQueryBuilder::parse(char const* config)
322324
token(IN_STRING, "&;");
323325
} break;
324326
case IN_END_VALUE: {
327+
QueryBuilderState nextState;
325328
if (*next == '&') {
326-
assignLastStringMatch("value", 1000, currentValue, IN_BEGIN_KEY);
327-
if (*currentKey == "lifetime" && currentValue == "condition") {
328-
currentLifetime = Lifetime::Condition;
329-
}
330-
if (*currentKey == "ccdb-run-dependent") {
331-
int val = currentValue == "false" ? 0 : (currentValue == "true" ? 1 : std::stoi(*currentValue));
332-
attributes.push_back(ConfigParamSpec{*currentKey, VariantType::Int, val, {}});
333-
} else {
334-
attributes.push_back(ConfigParamSpec{*currentKey, VariantType::String, *currentValue, {}});
335-
}
336-
} else if (*next == ';') {
337-
assignLastStringMatch("value", 1000, currentValue, IN_END_ATTRIBUTES);
338-
if (*currentKey == "lifetime" && currentValue == "condition") {
339-
currentLifetime = Lifetime::Condition;
340-
}
341-
if (*currentKey == "ccdb-run-dependent") {
342-
int val = currentValue == "false" ? 0 : (currentValue == "true" ? 1 : std::stoi(*currentValue));
343-
attributes.push_back(ConfigParamSpec{*currentKey, VariantType::Int, val, {}});
344-
} else {
345-
attributes.push_back(ConfigParamSpec{*currentKey, VariantType::String, *currentValue, {}});
346-
}
347-
} else if (*next == '\0') {
348-
assignLastStringMatch("value", 1000, currentValue, IN_END_ATTRIBUTES);
349-
if (*currentKey == "lifetime" && currentValue == "condition") {
350-
currentLifetime = Lifetime::Condition;
351-
}
352-
if (*currentKey == "ccdb-run-dependent") {
353-
int val = currentValue == "false" ? 0 : (currentValue == "true" ? 1 : std::stoi(*currentValue));
354-
attributes.push_back(ConfigParamSpec{*currentKey, VariantType::Int, val, {}});
355-
} else {
356-
attributes.push_back(ConfigParamSpec{*currentKey, VariantType::String, *currentValue, {}});
357-
}
329+
nextState = IN_BEGIN_KEY;
330+
} else if (*next == ';' || *next == '\0') {
331+
nextState = IN_END_ATTRIBUTES;
358332
} else {
359333
error("missing value for string value");
334+
continue;
335+
}
336+
if (!assignLastStringMatch("value", 1000, currentValue, nextState)) {
337+
continue; // The error is pushed and currentValue is not set.
338+
}
339+
if (*currentKey == "lifetime" && currentValue == "condition") {
340+
currentLifetime = Lifetime::Condition;
341+
}
342+
if (*currentKey == "ccdb-run-dependent") {
343+
int val = currentValue == "false" ? 0 : (currentValue == "true" ? 1 : std::stoi(*currentValue));
344+
attributes.push_back(ConfigParamSpec{*currentKey, VariantType::Int, val, {}});
345+
} else {
346+
attributes.push_back(ConfigParamSpec{*currentKey, VariantType::String, *currentValue, {}});
360347
}
361348
} break;
362349
case IN_END_ATTRIBUTES: {

0 commit comments

Comments
 (0)