diff --git a/xptifw/src/xpti_trace_framework.cpp b/xptifw/src/xpti_trace_framework.cpp index 750f858696d5..264ad2122ecc 100644 --- a/xptifw/src/xpti_trace_framework.cpp +++ b/xptifw/src/xpti_trace_framework.cpp @@ -1252,8 +1252,14 @@ class Tracepoints { if ((Payload->flags & static_cast(xpti::payload_flag_t::SourceFileAvailable))) { // Add source file information ot string table - FileId = + + // MStringTableRef.add returns a string_id_t which is an int32_t and can + // be negative, but negative values are unexpected in this context. + int32_t PFileId = MStringTableRef.add(Payload->source_file, &Payload->source_file); + + assert(PFileId >= 0 && "FileId can't be negative"); + FileId = static_cast(PFileId); } } else { // If the payload's function name is available, generate a fast hash as