diff options
| author | Mark Rowe <mark@vector35.com> | 2026-05-27 16:06:21 -0700 |
|---|---|---|
| committer | Mark Rowe <mark@vector35.com> | 2026-05-29 10:54:14 -0700 |
| commit | 68215ea14cfbaa4966f830d85d98f7f49b416455 (patch) | |
| tree | 92072cf169b172d3bb7df01c27dcf55532ac9701 /python | |
| parent | 9b7c23d8efa67a84b6c0779b0b4748cea699d403 (diff) | |
[Python] Ensure that BNFreeParseError is used to free the error returned by BNParseExpression
Diffstat (limited to 'python')
| -rw-r--r-- | python/binaryview.py | 2 | ||||
| -rw-r--r-- | python/generator.cpp | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index 5a63248f..d97e9f4d 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -10872,7 +10872,7 @@ to a the type "tagRECT" found in the typelibrary "winX64common" if not core.BNParseExpression(self.handle, expression, offset, here, errors): assert errors.value is not None, "core.BNParseExpression returned errors set to None" error_str = errors.value.decode("utf-8") - core.free_string(errors) + core.BNFreeParseError(ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte))) raise ValueError(error_str) return offset.value diff --git a/python/generator.cpp b/python/generator.cpp index 82eed91b..7ec2279a 100644 --- a/python/generator.cpp +++ b/python/generator.cpp @@ -504,7 +504,7 @@ int main(int argc, char* argv[]) // From python -> C python3 requires str -> str.encode('charmap') bool swizzleArgs = true; - if (name == "BNFreeString") + if (name == "BNFreeString" || name == "BNFreeParseError") swizzleArgs = false; bool callbackConvention = false; @@ -531,9 +531,9 @@ int main(int argc, char* argv[]) for (auto& j : i.second->GetParameters()) { fprintf(out, "\t\t"); - if (name == "BNFreeString") + if (name == "BNFreeString" || name == "BNFreeParseError") { - // BNFreeString expects a pointer to a string allocated by the core, so do not use + // These expect a pointer to a string allocated by the core, so do not use // a c_char_p here, as that would be allocated by the Python runtime. This can // be enforced by outputting like a return value. OutputType(out, j.type.GetValue(), true); |
