From f01f6e94d1487f2036ecee5daaf146d0d75bc409 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 24 May 2016 16:27:34 -0400 Subject: [PATCH] fix #500. check result of readline --- AddressBook.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AddressBook.cpp b/AddressBook.cpp index 766d8c95..40e4c383 100644 --- a/AddressBook.cpp +++ b/AddressBook.cpp @@ -716,12 +716,14 @@ namespace client if (status == 200) // OK { bool isChunked = false, isGzip = false; + m_Etag = ""; m_LastModified = ""; std::string header, statusMessage; std::getline (response, statusMessage); // read until new line meaning end of header while (!response.eof () && header != "\r") { std::getline (response, header); + if (response.fail ()) break; auto colon = header.find (':'); if (colon != std::string::npos) { @@ -741,7 +743,7 @@ namespace client } } LogPrint (eLogInfo, "Addressbook: received ", m_Link, " ETag: ", m_Etag, " Last-Modified: ", m_LastModified); - if (!response.eof ()) + if (!response.eof () && !response.fail ()) { success = true; if (!isChunked)