This is an archive of the discontinued LLVM Phabricator instance.

[NFC][CLANG] Fix nullptr dereference issue in DeduceTemplateArgumentsByTypeMatch()
ClosedPublic

Authored by Manna on May 25 2023, 7:48 PM.

Details

Summary

DeduceTemplateArgumentsByTypeMatch() returns null value which is dereferenced without checking since
getAsIncompleteArrayType() returns nullptr and we are dereferencing null pointer value for S.Context->getAsIncompleteArrayType(P) when calling getElementType().

This patch adds an assert.

Diff Detail

Event Timeline

Manna created this revision.May 25 2023, 7:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 7:48 PM
Manna requested review of this revision.May 25 2023, 7:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 7:48 PM
erichkeane accepted this revision.May 30 2023, 6:16 AM

1 nit to do on commit.

clang/lib/Sema/SemaTemplateDeduction.cpp
1707
This revision is now accepted and ready to land.May 30 2023, 6:16 AM
Manna updated this revision to Diff 526647.May 30 2023, 8:42 AM

Thank you @erichkeane for reviews!

I have updated assert message.

Manna marked an inline comment as done.May 30 2023, 8:42 AM
erichkeane accepted this revision.May 30 2023, 8:50 AM
This revision was automatically updated to reflect the committed changes.