# HG changeset patch
# User Ilya Etingof <etingof@gmail.com>
# Date 1573121946 -3600
#      Thu Nov 07 11:19:06 2019 +0100
# Node ID 362079c066d91e956edc9b82024db5735513312b
# Parent  916e08d0b71231cd84dd8a48e3ae42dc04390e92
Fix Integer decoder to handle empty payload

diff --git a/pyasn1/codec/ber/decoder.py b/pyasn1/codec/ber/decoder.py
--- a/pyasn1/codec/ber/decoder.py
+++ b/pyasn1/codec/ber/decoder.py
@@ -139,10 +139,11 @@
             if isinstance(chunk, SubstrateUnderrunError):
                 yield chunk
 
-        if not chunk:
-            yield self._createComponent(asn1Spec, tagSet, 0, **options)
-
-        value = from_bytes(chunk, signed=True)
+        if chunk:
+            value = from_bytes(chunk, signed=True)
+
+        else:
+            value = 0
 
         yield self._createComponent(asn1Spec, tagSet, value, **options)