Skip to content

Commit 5d6daa2

Browse files
committed
Check valobj for nullptr in UnaryConversion
1 parent 952512d commit 5d6daa2

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lldb/include/lldb/ValueObject/DILEval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Interpreter : Visitor {
6262
/// Perform usual unary conversions on a value. At the moment this
6363
/// includes array-to-pointer and integral promotion for eligible types.
6464
llvm::Expected<lldb::ValueObjectSP>
65-
UnaryConversion(lldb::ValueObjectSP valobj);
65+
UnaryConversion(lldb::ValueObjectSP valobj, uint32_t location);
6666
llvm::Expected<CompilerType>
6767
PickIntegerType(lldb::TypeSystemSP type_system,
6868
std::shared_ptr<ExecutionContextScope> ctx,

lldb/source/ValueObject/DILEval.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ ArrayToPointerConversion(ValueObject &valobj, ExecutionContextScope &ctx) {
5454
}
5555

5656
llvm::Expected<lldb::ValueObjectSP>
57-
Interpreter::UnaryConversion(lldb::ValueObjectSP valobj) {
57+
Interpreter::UnaryConversion(lldb::ValueObjectSP valobj, uint32_t location) {
58+
if (!valobj)
59+
return llvm::make_error<DILDiagnosticError>(m_expr, "invalid value object",
60+
location);
5861
llvm::Expected<lldb::TypeSystemSP> type_system =
5962
GetTypeSystemFromCU(m_exe_ctx_scope);
6063
if (!type_system)
@@ -311,7 +314,8 @@ Interpreter::Visit(const UnaryOpNode *node) {
311314
if (error.Fail())
312315
return error.ToError();
313316
}
314-
llvm::Expected<lldb::ValueObjectSP> conv_op = UnaryConversion(operand);
317+
llvm::Expected<lldb::ValueObjectSP> conv_op =
318+
UnaryConversion(operand, node->GetOperand()->GetLocation());
315319
if (!conv_op)
316320
return conv_op;
317321
operand = *conv_op;
@@ -340,7 +344,8 @@ Interpreter::Visit(const UnaryOpNode *node) {
340344
if (error.Fail())
341345
return error.ToError();
342346
}
343-
llvm::Expected<lldb::ValueObjectSP> conv_op = UnaryConversion(operand);
347+
llvm::Expected<lldb::ValueObjectSP> conv_op =
348+
UnaryConversion(operand, node->GetOperand()->GetLocation());
344349
if (!conv_op)
345350
return conv_op;
346351
operand = *conv_op;

0 commit comments

Comments
 (0)