mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Check for null FILE handles in ReportTopology
On Linux `/sys` is not guaranteed to exist. When it doesn't, tracy would crash with a SIGSEGV due to a nullptr dereference. Not actually sure how well tracy clients will handle the case where this information is missing, though.
This commit is contained in:
parent
b353eb753b
commit
b0d67064b5
@ -2692,12 +2692,15 @@ void Profiler::ReportTopology()
|
|||||||
sprintf( path, "%s%i/topology/physical_package_id", basePath, i );
|
sprintf( path, "%s%i/topology/physical_package_id", basePath, i );
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
FILE* f = fopen( path, "rb" );
|
FILE* f = fopen( path, "rb" );
|
||||||
|
if( f == nullptr ) {
|
||||||
|
tracy_free(cpuData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto read = fread( buf, 1, 1024, f );
|
auto read = fread( buf, 1, 1024, f );
|
||||||
buf[read] = '\0';
|
buf[read] = '\0';
|
||||||
fclose( f );
|
fclose( f );
|
||||||
cpuData[i].package = uint32_t( atoi( buf ) );
|
cpuData[i].package = uint32_t( atoi( buf ) );
|
||||||
cpuData[i].thread = i;
|
cpuData[i].thread = i;
|
||||||
|
|
||||||
sprintf( path, "%s%i/topology/core_id", basePath, i );
|
sprintf( path, "%s%i/topology/core_id", basePath, i );
|
||||||
f = fopen( path, "rb" );
|
f = fopen( path, "rb" );
|
||||||
read = fread( buf, 1, 1024, f );
|
read = fread( buf, 1, 1024, f );
|
||||||
|
Loading…
Reference in New Issue
Block a user