From 68e73eaee632b29d36e8b24f62e77ef26084885d Mon Sep 17 00:00:00 2001 From: David Spickett Date: Thu, 14 Apr 2022 14:06:27 +0000 Subject: [lldb] Handle empty search string in "memory find" Given that you'd never find empty string, just error. Also add a test that an invalid expr generates an error. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D123793 --- lldb/source/Commands/CommandObjectMemory.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lldb/source/Commands/CommandObjectMemory.cpp') diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index b7b28bc..4e63802 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -1052,9 +1052,14 @@ protected: DataBufferHeap buffer; - if (m_memory_options.m_string.OptionWasSet()) - buffer.CopyData(m_memory_options.m_string.GetStringValue()); - else if (m_memory_options.m_expr.OptionWasSet()) { + if (m_memory_options.m_string.OptionWasSet()) { + llvm::StringRef str = m_memory_options.m_string.GetStringValue(); + if (str.empty()) { + result.AppendError("search string must have non-zero length."); + return false; + } + buffer.CopyData(str); + } else if (m_memory_options.m_expr.OptionWasSet()) { StackFrame *frame = m_exe_ctx.GetFramePtr(); ValueObjectSP result_sp; if ((eExpressionCompleted == -- cgit v1.1