diff options
author | David Spickett <david.spickett@linaro.org> | 2022-04-14 14:06:27 +0000 |
---|---|---|
committer | David Spickett <david.spickett@linaro.org> | 2022-04-19 09:19:38 +0000 |
commit | 68e73eaee632b29d36e8b24f62e77ef26084885d (patch) | |
tree | 050cf7fbc1d4a26f648d45f964ffbdb3c49ae260 /lldb/source/Commands/CommandObjectMemory.cpp | |
parent | f3ee0afc6739bf2990f9d302ff6b28dbb0429e8d (diff) | |
download | llvm-68e73eaee632b29d36e8b24f62e77ef26084885d.zip llvm-68e73eaee632b29d36e8b24f62e77ef26084885d.tar.gz llvm-68e73eaee632b29d36e8b24f62e77ef26084885d.tar.bz2 |
[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
Diffstat (limited to 'lldb/source/Commands/CommandObjectMemory.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectMemory.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
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 == |