The StringRef single argument constructor expects a null-terminated
string. Explicitly pass the size to prevent reading pass the end
of the array.
if (!cpuinfo)
return cpuinfo.takeError();
- Expected<std::vector<int>> core_ids = GetAvailableLogicalCoreIDs(
- StringRef(reinterpret_cast<const char *>(cpuinfo->data())));
+ Expected<std::vector<int>> core_ids = GetAvailableLogicalCoreIDs(StringRef(
+ reinterpret_cast<const char *>(cpuinfo->data()), cpuinfo->size()));
if (!core_ids)
return core_ids.takeError();