This is an archive of the discontinued LLVM Phabricator instance.

[NFC]Add assert to avoid deref nullptr
AbandonedPublic

Authored by XinWang10 on Aug 8 2023, 8:08 PM.

Details

Reviewers
Pierre-vh
Summary

Static analyzer reports dyn_cast at line 970 could return nullptr which could lead to security issue when deref it at line 971.
I think author could confirm the ptr Code could always be StringInit type here so I add assert to avoid static analyzer report.

Diff Detail

Unit TestsFailed

Event Timeline

XinWang10 created this revision.Aug 8 2023, 8:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2023, 8:08 PM
XinWang10 requested review of this revision.Aug 8 2023, 8:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2023, 8:08 PM
Pierre-vh accepted this revision.Aug 9 2023, 12:17 AM

Thanks for the fix! It's good to commit as-is if you want a quick fix, but the version I propose is the best possible user experience.
Note it's all going away in D156315 anyway.

llvm/utils/TableGen/GlobalISelCombinerMatchTableEmitter.cpp
970–973

Ideally do this, otherwise just change the dyn_cast to a cast and it'll just assert if it's the wrong type.

This revision is now accepted and ready to land.Aug 9 2023, 12:17 AM

OK, Thanks for explanation. Since it will be a big change in D156315 and this issue could disappear, I would abandon this unnecessary revision.

XinWang10 abandoned this revision.Aug 9 2023, 12:32 AM