Explorar el Código

Add empty PB input check

Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
Vadim Markovtsev hace 6 años
padre
commit
eeae1e0de3
Se han modificado 1 ficheros con 5 adiciones y 2 borrados
  1. 5 2
      labours.py

+ 5 - 2
labours.py

@@ -262,9 +262,12 @@ class ProtobufReader(Reader):
         self.data = AnalysisResults()
         if file != "-":
             with open(file, "rb") as fin:
-                self.data.ParseFromString(fin.read())
+                bytes = fin.read()
         else:
-            self.data.ParseFromString(sys.stdin.buffer.read())
+            bytes = sys.stdin.buffer.read()
+        if not bytes:
+            raise ValueError("empty input")
+        self.data.ParseFromString(bytes)
         self.contents = {}
         for key, val in self.data.contents.items():
             try: