From 260cc42c2f635bafcff3e5aa574528759db52096 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Mon, 10 Jun 2024 14:32:42 +1200 Subject: [PATCH] rtlil.cc: Fix decode for empty string --- kernel/rtlil.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index eb3fc938aef..50e28bba7d0 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -337,7 +337,10 @@ std::string RTLIL::Const::decode_string() const } s.append({ch}); } - return s.substr(s.find_first_not_of('\0')); + auto first_char = s.find_first_not_of('\0'); + if (first_char != std::string::npos) + return s.substr(first_char); + else return s; } bool RTLIL::Const::is_fully_zero() const