@@ -326,11 +326,16 @@ static int split_target(
326326 return -1 ;
327327}
328328
329+ static void release_parent_guard (DynlexWindowsStaging * staging ) {
330+ if (staging -> parent != INVALID_HANDLE_VALUE )
331+ CloseHandle (staging -> parent );
332+ staging -> parent = INVALID_HANDLE_VALUE ;
333+ }
334+
329335static void destroy_staging (DynlexWindowsStaging * staging ) {
330336 if (staging -> staging != INVALID_HANDLE_VALUE )
331337 CloseHandle (staging -> staging );
332- if (staging -> parent != INVALID_HANDLE_VALUE )
333- CloseHandle (staging -> parent );
338+ release_parent_guard (staging );
334339 free (staging -> parent_path );
335340 free (staging -> destination_name );
336341 free (staging -> destination_path );
@@ -485,6 +490,7 @@ static int delete_stage(DynlexWindowsStaging *staging, int32_t failure_operation
485490 CloseHandle (staging -> staging );
486491 staging -> staging = INVALID_HANDLE_VALUE ;
487492 staging -> stage_name_present = false;
493+ release_parent_guard (staging );
488494 return 0 ;
489495}
490496
@@ -751,6 +757,7 @@ int dynlex_filesystem_staging_commit(
751757 staging -> state = DYNLEX_FILESYSTEM_STAGING_CLEANUP_FAILED ;
752758 return -1 ;
753759 }
760+ release_parent_guard (staging );
754761 * cleanup_succeeded = 1 ;
755762 staging -> state = DYNLEX_FILESYSTEM_STAGING_COMMITTED ;
756763 return 0 ;
0 commit comments