Petr Onderka has submitted this change and it was merged.

Change subject: Fixed exception when reading near end of stream
......................................................................


Fixed exception when reading near end of stream

Change-Id: I13e04af52d293cbb5aff78521a2c56e2771ed3e1
---
M XmlInput/WrapperInputStream.h
M main.cpp
2 files changed, 9 insertions(+), 2 deletions(-)

Approvals:
  Petr Onderka: Verified; Looks good to me, approved



diff --git a/XmlInput/WrapperInputStream.h b/XmlInput/WrapperInputStream.h
index ea11593..e9d8426 100644
--- a/XmlInput/WrapperInputStream.h
+++ b/XmlInput/WrapperInputStream.h
@@ -21,6 +21,13 @@
         wrapped.read(buf, bufLen);
         auto count = wrapped.gcount();
 
+        if (!wrapped.good())
+        {
+            // failure that's not end of stream
+            if (!wrapped.eof() && wrapped.fail())
+                throw DumpException("Reading from stream failed.");
+        }
+
         if (sideAction != nullptr)
             sideAction(count);
 
diff --git a/main.cpp b/main.cpp
index 2baff49..caddb02 100644
--- a/main.cpp
+++ b/main.cpp
@@ -211,13 +211,13 @@
 
     if (inputFileName == "-")
     {
-        std::cin.exceptions(std::ios::failbit | std::ios::badbit);
+        std::cin.exceptions(std::ios::badbit);
         createDumpCore(progressWriter, std::cin);
     }
     else
     {
         std::ifstream stream(inputFileName, std::ios::binary);
-        stream.exceptions(std::ios::failbit | std::ios::badbit);
+        stream.exceptions(std::ios::badbit);
         createDumpCore(progressWriter, stream);
     }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/85196
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I13e04af52d293cbb5aff78521a2c56e2771ed3e1
Gerrit-PatchSet: 1
Gerrit-Project: operations/dumps/incremental
Gerrit-Branch: gsoc
Gerrit-Owner: Petr Onderka <[email protected]>
Gerrit-Reviewer: Petr Onderka <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to