Skip to content

Commit fcdd200

Browse files
committed
Fix memory leak in write_tree
1 parent fe17f7a commit fcdd200

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

extract-xiso.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ int decode_xiso( char *in_xiso, char *in_path, modes in_mode, char **out_iso_pat
11871187

11881188
if ( short_name ) free( short_name );
11891189
if ( cwd ) {
1190-
chdir( cwd );
1190+
if (chdir(cwd) == -1) chdir_err(cwd);
11911191
free( cwd );
11921192
}
11931193

@@ -1700,13 +1700,13 @@ int write_tree( dir_node_avl *in_avl, write_tree_context *in_context, int in_dep
17001700
if ( ! err && in_context->from == -1 ) {
17011701
if ( chdir( ".." ) == -1 ) chdir_err( ".." );
17021702
}
1703-
1704-
if ( context.path ) free( context.path );
17051703
} else {
17061704
memset(sector, XISO_PAD_BYTE, XISO_SECTOR_SIZE);
17071705
if ((pos = lseek(in_context->xiso, in_avl->start_sector * XISO_SECTOR_SIZE, SEEK_SET)) == -1) seek_err();
17081706
if (!err && write(in_context->xiso, sector, XISO_SECTOR_SIZE) != XISO_SECTOR_SIZE) write_err();
17091707
}
1708+
1709+
if (context.path) free(context.path);
17101710
}
17111711
}
17121712

0 commit comments

Comments
 (0)