File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -1388,8 +1388,11 @@ def wrapped_callback(
13881388 if data_len > 1024 * 1024 : # 1MB limit
13891389 return - 1
13901390
1391- # Convert C pointer to Python bytes using direct memory access
1392- data = bytes (ctypes .cast (data_ptr , ctypes .POINTER (ctypes .c_ubyte * data_len )).contents )
1391+ # Recover signed data (copy, to avoid lifetime issues)
1392+ temp_buffer = (ctypes .c_ubyte * data_len )()
1393+ ctypes .memmove (temp_buffer , data_ptr , data_len )
1394+ data = bytes (temp_buffer )
1395+
13931396 if not data :
13941397 # Error: empty data, invalid so return -1,
13951398 # native code will also handle it!
@@ -1874,7 +1877,9 @@ def _sign_internal(
18741877 if manifest_bytes_ptr and result > 0 :
18751878 try :
18761879 # Convert the C pointer to Python bytes
1877- manifest_bytes = bytes (manifest_bytes_ptr [:result ])
1880+ temp_buffer = (ctypes .c_ubyte * result )()
1881+ ctypes .memmove (temp_buffer , manifest_bytes_ptr , result )
1882+ manifest_bytes = bytes (temp_buffer )
18781883 except Exception :
18791884 # If there's any error accessing the memory, just return
18801885 # empty bytes
You can’t perform that action at this time.
0 commit comments