Skip to content

Commit e827137

Browse files
XLS Teamcopybara-github
authored andcommitted
Fix a use-after-free bug in xls/visualization/sched_printer_main.cc.
PiperOrigin-RevId: 681567169
1 parent c82c620 commit e827137

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

xls/visualization/sched_printer_main.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,10 @@ absl::Status RealMain(std::string_view ir_path) {
347347
XLS_RETURN_IF_ERROR(VerifyPackage(p.get()));
348348

349349
std::string top_str = absl::GetFlag(FLAGS_top);
350-
std::optional<std::string_view> maybe_top_str =
351-
top_str.empty() ? std::nullopt : std::make_optional(top_str);
350+
std::optional<std::string_view> maybe_top_str;
351+
if (!top_str.empty()) {
352+
maybe_top_str = top_str;
353+
}
352354
XLS_ASSIGN_OR_RETURN(FunctionBase * main, FindTop(p.get(), maybe_top_str));
353355

354356
XLS_ASSIGN_OR_RETURN(

0 commit comments

Comments
 (0)