From 64a781b636755330c9283f9ff830f49bc1484647 Mon Sep 17 00:00:00 2001 From: rapperskull Date: Mon, 6 Mar 2023 00:59:15 +0100 Subject: [PATCH] Fix memory leak in write_tree --- extract-xiso.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extract-xiso.c b/extract-xiso.c index 7c9a4a4..0863b26 100644 --- a/extract-xiso.c +++ b/extract-xiso.c @@ -1185,7 +1185,7 @@ int decode_xiso( char *in_xiso, char *in_path, modes in_mode, char **out_iso_pat if ( short_name ) free( short_name ); if ( cwd ) { - chdir( cwd ); + if (chdir(cwd) == -1) chdir_err(cwd); free( cwd ); } @@ -1698,13 +1698,13 @@ int write_tree( dir_node_avl *in_avl, write_tree_context *in_context, int in_dep if ( ! err && in_context->from == -1 ) { if ( chdir( ".." ) == -1 ) chdir_err( ".." ); } - - if ( context.path ) free( context.path ); } else { memset(sector, XISO_PAD_BYTE, XISO_SECTOR_SIZE); if ((pos = lseek(in_context->xiso, in_avl->start_sector * XISO_SECTOR_SIZE, SEEK_SET)) == -1) seek_err(); if (!err && write(in_context->xiso, sector, XISO_SECTOR_SIZE) != XISO_SECTOR_SIZE) write_err(); } + + if (context.path) free(context.path); } }