From 8e5bb9348dd921ccfb432082bdfed142dd27ebd7 Mon Sep 17 00:00:00 2001 From: "thestig@chromium.org" Date: Fri, 31 Aug 2012 03:47:40 +0000 Subject: Linux: Better detect a race in /proc/pid/stats reading code. BUG=145811 Review URL: https://chromiumcodereview.appspot.com/10916031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154367 0039d316-1c4b-4281-b951-d872f2087c98 --- base/process_util_linux.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'base/process_util_linux.cc') diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc index 34e7d7c..393295a 100644 --- a/base/process_util_linux.cc +++ b/base/process_util_linux.cc @@ -68,6 +68,11 @@ bool ReadProcStats(pid_t pid, std::string* buffer) { // Returns true if successful. bool ParseProcStats(const std::string& stats_data, std::vector* proc_stats) { + // |stats_data| may be empty if the process disappeared somehow. + // e.g. http://crbug.com/145811 + if (stats_data.empty()) + return false; + // The stat file is formatted as: // pid (process name) data1 data2 .... dataN // Look for the closing paren by scanning backwards, to avoid being fooled by -- cgit v1.1