We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cab64dc commit 19145d7Copy full SHA for 19145d7
1 file changed
libdestruct/common/struct/struct.py
@@ -13,6 +13,7 @@
13
if TYPE_CHECKING:
14
from libdestruct.common.struct.struct_impl import struct_impl
15
16
+
17
class struct(obj):
18
"""A C struct."""
19
@@ -27,4 +28,9 @@ def from_bytes(cls: type[struct], data: bytes) -> struct_impl:
27
28
29
type_inflater = inflater(data)
30
- return type_inflater.inflate_struct(cls, 0)
31
+ result = type_inflater.inflate_struct(cls, 0)
32
33
+ if result.size != len(data):
34
+ raise ValueError("The length of the serialized struct does not match the struct size.")
35
36
+ return result
0 commit comments