Skip to content

Commit 64a781b

Browse files
committed
Fix memory leak in write_tree
1 parent d15cf13 commit 64a781b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

extract-xiso.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ int decode_xiso( char *in_xiso, char *in_path, modes in_mode, char **out_iso_pat
11851185

11861186
if ( short_name ) free( short_name );
11871187
if ( cwd ) {
1188-
chdir( cwd );
1188+
if (chdir(cwd) == -1) chdir_err(cwd);
11891189
free( cwd );
11901190
}
11911191

@@ -1698,13 +1698,13 @@ int write_tree( dir_node_avl *in_avl, write_tree_context *in_context, int in_dep
16981698
if ( ! err && in_context->from == -1 ) {
16991699
if ( chdir( ".." ) == -1 ) chdir_err( ".." );
17001700
}
1701-
1702-
if ( context.path ) free( context.path );
17031701
} else {
17041702
memset(sector, XISO_PAD_BYTE, XISO_SECTOR_SIZE);
17051703
if ((pos = lseek(in_context->xiso, in_avl->start_sector * XISO_SECTOR_SIZE, SEEK_SET)) == -1) seek_err();
17061704
if (!err && write(in_context->xiso, sector, XISO_SECTOR_SIZE) != XISO_SECTOR_SIZE) write_err();
17071705
}
1706+
1707+
if (context.path) free(context.path);
17081708
}
17091709
}
17101710

0 commit comments

Comments
 (0)