From 9047f69db4d338e0e7ed6c93dbfc35054eb89d16 Mon Sep 17 00:00:00 2001 From: Thierry Treyer Date: Mon, 11 Dec 2023 11:03:10 -0800 Subject: [PATCH] Check bounds when processing unique_ptr --- oi/OICodeGen.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/oi/OICodeGen.cpp b/oi/OICodeGen.cpp index f25cb90..49cbf9b 100644 --- a/oi/OICodeGen.cpp +++ b/oi/OICodeGen.cpp @@ -165,8 +165,13 @@ std::string OICodeGen::preProcessUniquePtr(drgn_type* type, std::string name) { std::string typeName; std::string deleterName; - size_t end = name.rfind('>') - 1; - size_t pos = end; + size_t end = name.rfind('>'); + if (end == std::string::npos) { + LOG(ERROR) << "No template parameter for the unique_ptr " << type; + return name; + } + + size_t pos = end = end - 1; // Skip the '>' found size_t begin = 0; bool found = false;