@@ -812,7 +812,7 @@ int main( int argc, char **argv ) {
812812 if ( ! err && stat ( buf , & sb ) != -1 ) misc_err ( "%s already exists, cannot rewrite %s" , buf , argv [ i ] );
813813 if ( ! err && rename ( argv [ i ], buf ) == -1 ) misc_err ( "cannot rename %s to %s" , argv [ i ], buf );
814814
815- if ( err ) { err = 0 ; free ( buf ); continue ; }
815+ if ( err ) { err = 0 ; if ( buf ) free ( buf ); continue ; }
816816 }
817817 if ( ! err ) err = decode_xiso ( buf , path , k_rewrite , & new_iso_path );
818818 if ( ! err && delete && unlink ( buf ) == -1 ) log_err ( __FILE__ , __LINE__ , "unable to delete %s" , buf );
@@ -1022,8 +1022,11 @@ int create_xiso( char *in_root_directory, char *in_output_directory, dir_node_av
10221022 if ( ! err && ( buf = (char * ) malloc ( n = max ( READWRITE_BUFFER_SIZE , XISO_HEADER_OFFSET ) ) ) == nil ) mem_err ();
10231023 if ( ! err ) {
10241024 if ( ( xiso = open ( xiso_path , WRITEFLAGS , 0644 ) ) == -1 ) open_err ( xiso_path );
1025- if ( out_iso_path ) * out_iso_path = xiso_path ;
1026- else free ( xiso_path );
1025+ if (out_iso_path ) * out_iso_path = xiso_path ;
1026+ else {
1027+ free (xiso_path );
1028+ xiso_path = nil ;
1029+ }
10271030 }
10281031 if ( ! err ) {
10291032 memset ( buf , 0 , n );
@@ -1087,7 +1090,7 @@ int create_xiso( char *in_root_directory, char *in_output_directory, dir_node_av
10871090
10881091 if ( xiso != -1 ) {
10891092 close ( xiso );
1090- if ( err ) unlink ( xiso_path );
1093+ if (err && xiso_path ) unlink (xiso_path );
10911094 }
10921095
10931096 if ( root .filename ) free ( root .filename );
@@ -1216,7 +1219,7 @@ int traverse_xiso(int in_xiso, xoff_t in_dir_start, uint16_t entry_offset, char*
12161219 }
12171220
12181221 // Read node
1219- if (!err ) if (! (node = calloc (1 , sizeof (dir_node )))) mem_err ();
1222+ if (!err ) if ((node = calloc (1 , sizeof (dir_node ))) == nil ) mem_err ();
12201223 if (!err && read (in_xiso , & r_offset , XISO_TABLE_OFFSET_SIZE ) != XISO_TABLE_OFFSET_SIZE ) read_err ();
12211224 if (!err && read (in_xiso , & node -> start_sector , XISO_SECTOR_OFFSET_SIZE ) != XISO_SECTOR_OFFSET_SIZE ) read_err ();
12221225 if (!err && read (in_xiso , & node -> file_size , XISO_FILESIZE_SIZE ) != XISO_FILESIZE_SIZE ) read_err ();
@@ -1260,8 +1263,10 @@ int traverse_xiso(int in_xiso, xoff_t in_dir_start, uint16_t entry_offset, char*
12601263 if (!err ) err = process_node (in_xiso , node , in_path , in_mode , (in_mode == k_generate_avl ) ? & avl -> subdirectory : nil );
12611264
12621265 // Free memory before recurring
1263- if (node -> filename ) free (node -> filename );
1264- if (node ) free (node );
1266+ if (node ) {
1267+ if (node -> filename ) free (node -> filename );
1268+ free (node );
1269+ }
12651270
12661271 // Repeat on left node
12671272 if (!err && l_offset ) {
0 commit comments