This is an archive of the discontinued LLVM Phabricator instance.

Fix dereferencing null pointer
Needs ReviewPublic

Authored by zloyrobot on Apr 22 2019, 5:28 AM.

Details

Reviewers
amccarth
thakis
Summary

All callers of Demangler::parseTagUniqueName check 'Demangler.Error' and assume that 'Error is false' means 'return value is not null'

Diff Detail

Repository
rLLDB LLDB

Event Timeline

zloyrobot created this revision.Apr 22 2019, 5:28 AM

test?

Would you please advise me on what kind of test I should add for such fix?

kind reminder

Add a test that fails without the code change and that passes with it. I don't know under which conditions this change is needed, so I apologize that I can't make a more concrete suggestion.

kwk added a subscriber: kwk.Aug 13 2019, 5:49 AM
kwk added inline comments.
llvm/lib/Demangle/MicrosoftDemangle.cpp
737

Why not change the return type to llvm::Expected<TagTypeNode>? Then you have one return value that is either an error (when return value evaluates to false) or the value. On top of just a boolean Error variable you then can also use the return value to store error texts if you need them. Now, I don't know if the Error member is used anywhere else.

thakis added inline comments.Aug 13 2019, 7:53 AM
llvm/lib/Demangle/MicrosoftDemangle.cpp
737

Error is not a parameter, it's class-level state that's used pervasively in this file.

kwk marked an inline comment as done.Aug 19 2019, 12:42 AM
kwk added inline comments.
llvm/lib/Demangle/MicrosoftDemangle.cpp
737

Okay, was just a thought. Thanks for explaining.