Skip to content

Commit cefbedd

Browse files
committed
DPL: fix use after free spotted by ASAN
1 parent 4e7fcd0 commit cefbedd

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

Framework/Core/src/runDataProcessing.cxx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,14 @@ struct ControlWebSocketHandler : public WebSocketHandler {
509509
ParsedConfigMatch configMatch;
510510
ParsedMetricMatch metricMatch;
511511

512+
auto doParseConfig = [](std::string const& token, ParsedConfigMatch& configMatch, DeviceInfo& info) -> bool {
513+
auto ts = " " + token;
514+
if (DeviceConfigHelper::parseConfig(ts, configMatch)) {
515+
DeviceConfigHelper::processConfig(configMatch, info);
516+
return true;
517+
}
518+
return false;
519+
};
512520
LOG(debug3) << "Data received: " << std::string_view(frame, s);
513521
if (DeviceMetricsHelper::parseMetric(token, metricMatch)) {
514522
// We use this callback to cache which metrics are needed to provide a
@@ -517,13 +525,10 @@ struct ControlWebSocketHandler : public WebSocketHandler {
517525
DeviceMetricsHelper::processMetric(metricMatch, (*mContext.metrics)[mIndex], newMetricCallback);
518526
didProcessMetric = true;
519527
didHaveNewMetric |= hasNewMetric;
520-
} else if (ControlServiceHelpers::parseControl(token, match)) {
521-
assert(mContext.infos);
528+
} else if (ControlServiceHelpers::parseControl(token, match) && mContext.infos) {
522529
ControlServiceHelpers::processCommand(*mContext.infos, mPid, match[1].str(), match[2].str());
523-
} else if (DeviceConfigHelper::parseConfig(std::string{" "} + token, configMatch)) {
530+
} else if (doParseConfig(token, configMatch, (*mContext.infos)[mIndex]) && mContext.infos) {
524531
LOG(debug2) << "Found configuration information for pid " << mPid;
525-
assert(mContext.infos);
526-
DeviceConfigHelper::processConfig(configMatch, (*mContext.infos)[mIndex]);
527532
} else {
528533
LOG(error) << "Unexpected control data: " << std::string_view(frame, s);
529534
}

0 commit comments

Comments
 (0)