diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index df5409b..cab8e51 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -3382,12 +3382,16 @@ get_appid_from_pid( pid_t pid ) { snprintf( filename, sizeof( filename ), "/proc/%i/stat", next_pid ); std::ifstream proc_stat_file( filename ); + + if (!proc_stat_file.is_open() || proc_stat_file.bad()) + break; + std::string proc_stat; std::getline( proc_stat_file, proc_stat ); char *procName = nullptr; - char *lastParens; + char *lastParens = nullptr; for ( uint32_t i = 0; i < proc_stat.length(); i++ ) { @@ -3402,6 +3406,9 @@ get_appid_from_pid( pid_t pid ) } } + if (!lastParens) + break; + *lastParens = '\0'; char state; int parent_pid = -1;