diff options
| author | Peter LaFosse <peter@vector35.com> | 2021-06-23 10:57:05 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2021-09-05 10:08:09 -0400 |
| commit | 3be2c0f9d4574f84869e5dcc61a91b4356391207 (patch) | |
| tree | 5ae2e1bea06b9d47f7b07a89414ac79006d4643d /python/types.py | |
| parent | c04f530ffe11ec62d3e23b0cbb445200ecbed026 (diff) | |
add a core.free_string helper
Diffstat (limited to 'python/types.py')
| -rw-r--r-- | python/types.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/python/types.py b/python/types.py index 3cd44bd8..87fa7ddb 100644 --- a/python/types.py +++ b/python/types.py @@ -1662,10 +1662,12 @@ def preprocess_source(source, filename=None, include_dirs=[]): output = ctypes.c_char_p() errors = ctypes.c_char_p() result = core.BNPreprocessSource(source, filename, output, errors, dir_buf, len(include_dirs)) - output_str = output.value - error_str = errors.value - core.BNFreeString(ctypes.cast(output, ctypes.POINTER(ctypes.c_byte))) - core.BNFreeString(ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte))) + assert output.value is not None + assert errors.value is not None + output_str = output.value.decode('utf-8') + error_str = errors.value.decode('utf-8') + core.free_string(output) + core.free_string(errors) if result: return (output_str, error_str) return (None, error_str) |
