diff options
author | Qingning Huo <qingninghuo@gmail.com> | 2012-02-04 20:30:01 (GMT) |
---|---|---|
committer | Qingning Huo <qingninghuo@gmail.com> | 2012-02-04 20:30:01 (GMT) |
commit | 33d3c2d9ae50b3c6142ccfd09b82ed0cbba607ab (patch) | |
tree | bdee6edfde15e06fd9028e91393b81cd9572aaa0 /src | |
parent | 06315b1e2e2db9ba5dbb1d4ecf91344846c0de3a (diff) | |
download | Ninja-33d3c2d9ae50b3c6142ccfd09b82ed0cbba607ab.zip Ninja-33d3c2d9ae50b3c6142ccfd09b82ed0cbba607ab.tar.gz Ninja-33d3c2d9ae50b3c6142ccfd09b82ed0cbba607ab.tar.bz2 |
Avoid using undefined value in Subprocess::OnPipeReady()
Diffstat (limited to 'src')
-rw-r--r-- | src/subprocess-win32.cc | 5 | ||||
-rw-r--r-- | src/subprocess.h | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/subprocess-win32.cc b/src/subprocess-win32.cc index e757f7e..c0185e4 100644 --- a/src/subprocess-win32.cc +++ b/src/subprocess-win32.cc @@ -28,7 +28,7 @@ void Win32Fatal(const char* function) { } // anonymous namespace -Subprocess::Subprocess() : child_(NULL) , overlapped_() { +Subprocess::Subprocess() : child_(NULL) , overlapped_(), is_reading_(false) { } Subprocess::~Subprocess() { @@ -130,10 +130,11 @@ void Subprocess::OnPipeReady() { Win32Fatal("GetOverlappedResult"); } - if (bytes) + if (is_reading_ && bytes) buf_.append(overlapped_buf_, bytes); memset(&overlapped_, 0, sizeof(overlapped_)); + is_reading_ = true; if (!::ReadFile(pipe_, overlapped_buf_, sizeof(overlapped_buf_), &bytes, &overlapped_)) { if (GetLastError() == ERROR_BROKEN_PIPE) { diff --git a/src/subprocess.h b/src/subprocess.h index 9828bf4..f355944 100644 --- a/src/subprocess.h +++ b/src/subprocess.h @@ -52,6 +52,7 @@ struct Subprocess { HANDLE pipe_; OVERLAPPED overlapped_; char overlapped_buf_[4 << 10]; + bool is_reading_; #else int fd_; pid_t pid_; |