pfp
pfp copied to clipboard
calling _pfp__set_value on a Struct always raises an exception
Describe the bug
Calling fields.Struct._pfp__set_value
always results in a NameError
exception. This is because of a typo in a variable name in this function.
To Reproduce
Here is a test reproducing the error:
def test_struct_set_value(self):
dom = self._test_parse_build(
"abc",
"""
typedef struct {
char first;
char second;
char third;
} three_bytes;
three_bytes bytes;
""",
)
dom.bytes._pfp__set_value([ord("x"), ord("y"), ord("z")])
self.assertEqual(dom.bytes.first, ord("x"))
self.assertEqual(dom.bytes.second, ord("y"))
self.assertEqual(dom.bytes.third, ord("z"))
resulting in the following error:
Traceback (most recent call last):
File "pfp/tests/test_struct_union_2.py", line 479, in test_struct_set_value
dom.bytes._pfp__set_value([ord("x"), ord("y"), ord("z")])
File "pfp/tests/../pfp/fields.py", line 835, in _pfp__set_value
return modified_watches
NameError: name 'modified_watches' is not defined
Expected Behavior
Calling _pfp__set_value
should replace the current struct value with the argument, overwriting the struct's children.