Skip to content

Commit b619438

Browse files
[XPTI] Add assert to prevent unintentional integer underflow. (#19205)
Coverity flagged this. Fixes #18513
1 parent b747578 commit b619438

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

xptifw/src/xpti_trace_framework.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,8 +1252,14 @@ class Tracepoints {
12521252
if ((Payload->flags &
12531253
static_cast<uint64_t>(xpti::payload_flag_t::SourceFileAvailable))) {
12541254
// Add source file information ot string table
1255-
FileId =
1255+
1256+
// MStringTableRef.add returns a string_id_t which is an int32_t and can
1257+
// be negative, but negative values are unexpected in this context.
1258+
int32_t PFileId =
12561259
MStringTableRef.add(Payload->source_file, &Payload->source_file);
1260+
1261+
assert(PFileId >= 0 && "FileId can't be negative");
1262+
FileId = static_cast<uint64_t>(PFileId);
12571263
}
12581264
} else {
12591265
// If the payload's function name is available, generate a fast hash as

0 commit comments

Comments
 (0)