From d4b8f9ee93f3f98ff7452425c622e61e51ff7ca7 Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Tue, 3 Nov 2009 19:10:22 +0000 Subject: [PATCH] Make this code more robust by not thinking we are making progress if zero bytes were read. llvm-svn: 85922 --- lib/Support/MemoryBuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index e35c626c408..d8b6b9f76fe 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -226,7 +226,7 @@ MemoryBuffer *MemoryBuffer::getFile(const char *Filename, std::string *ErrStr, size_t BytesLeft = FileSize; while (BytesLeft) { ssize_t NumRead = ::read(FD, BufPtr, BytesLeft); - if (NumRead != -1) { + if (NumRead > 0) { BytesLeft -= NumRead; BufPtr += NumRead; } else if (errno == EINTR) {