Skip to content

Commit 9541149

Browse files
Jongyyonghong-song
authored andcommitted
Fix perf_submit() calls with array data crashing libbcc
A perf_submit() call like: unsigned char buf[16] = ...; output.perf_submit(ctx, buf, sizeof(buf)); Passes a non-pointer arg1, so getPointeeType().getTypePtr() is invalid, and crashes libbcc. Use getTypePtrOrNull() instead to avoid it. Signed-off-by: Yonatan Goldschmidt <[email protected]>
1 parent 8fac710 commit 9541149

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cc/frontends/clang/b_frontend_action.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,8 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
925925
// events.perf_submit(ctx, &data, sizeof(data));
926926
// ...
927927
// &data -> data -> typeof(data) -> data_t
928-
auto type_arg1 = Call->getArg(1)->IgnoreCasts()->getType().getTypePtr()->getPointeeType().getTypePtr();
929-
if (type_arg1->isStructureType()) {
928+
auto type_arg1 = Call->getArg(1)->IgnoreCasts()->getType().getTypePtr()->getPointeeType().getTypePtrOrNull();
929+
if (type_arg1 && type_arg1->isStructureType()) {
930930
auto event_type = type_arg1->getAsTagDecl();
931931
const auto *r = dyn_cast<RecordDecl>(event_type);
932932
std::vector<std::string> perf_event;

0 commit comments

Comments
 (0)