Skip to content

Commit

Permalink
Always free
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Dec 17, 2024
1 parent 8fb4b96 commit 92dd9e4
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions IPython/utils/_process_win32.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,18 @@ def arg_split(
return py_arg_split(commandline, posix=posix, strict=strict)
argvn = c_int()
result_pointer = CommandLineToArgvW(commandline.lstrip(), ctypes.byref(argvn))
result_array_type = LPCWSTR * argvn.value
result = [
arg
for arg in result_array_type.from_address(
ctypes.addressof(result_pointer.contents)
)
if arg is not None
]
# for side effects
_ = LocalFree(result_pointer)
try:
result_array_type = LPCWSTR * argvn.value
result = [
arg
for arg in result_array_type.from_address(
ctypes.addressof(result_pointer.contents)
)
if arg is not None
]
finally:
# for side effects
_ = LocalFree(result_pointer)
return result
except AttributeError:
arg_split = py_arg_split
Expand Down

0 comments on commit 92dd9e4

Please sign in to comment.