Merge pull request #60 from nagisa/nagisa/dont-sigsegv-file

Check for null FILE handles in ReportTopology
This commit is contained in:
Bartosz Taudul 2020-06-21 20:06:22 +02:00 committed by GitHub
commit 493d433330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2692,12 +2692,15 @@ void Profiler::ReportTopology()
sprintf( path, "%s%i/topology/physical_package_id", basePath, i );
char buf[1024];
FILE* f = fopen( path, "rb" );
if( f == nullptr ) {
tracy_free(cpuData);
return;
}
auto read = fread( buf, 1, 1024, f );
buf[read] = '\0';
fclose( f );
cpuData[i].package = uint32_t( atoi( buf ) );
cpuData[i].thread = i;
sprintf( path, "%s%i/topology/core_id", basePath, i );
f = fopen( path, "rb" );
read = fread( buf, 1, 1024, f );