@@ -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 );
@@ -1090,7 +1093,7 @@ int create_xiso( char *in_root_directory, char *in_output_directory, dir_node_av
10901093
10911094 if ( xiso != -1 ) {
10921095 close ( xiso );
1093- if ( err ) unlink ( xiso_path );
1096+ if (err && xiso_path ) unlink (xiso_path );
10941097 }
10951098
10961099 if ( root .filename ) free ( root .filename );
@@ -1219,7 +1222,7 @@ int traverse_xiso(int in_xiso, xoff_t in_dir_start, uint16_t entry_offset, char*
12191222 }
12201223
12211224 // Read node
1222- if (!err ) if (! (node = calloc (1 , sizeof (dir_node )))) mem_err ();
1225+ if (!err ) if ((node = calloc (1 , sizeof (dir_node ))) == nil ) mem_err ();
12231226 if (!err && read (in_xiso , & r_offset , XISO_TABLE_OFFSET_SIZE ) != XISO_TABLE_OFFSET_SIZE ) read_err ();
12241227 if (!err && read (in_xiso , & node -> start_sector , XISO_SECTOR_OFFSET_SIZE ) != XISO_SECTOR_OFFSET_SIZE ) read_err ();
12251228 if (!err && read (in_xiso , & node -> file_size , XISO_FILESIZE_SIZE ) != XISO_FILESIZE_SIZE ) read_err ();
@@ -1263,8 +1266,10 @@ int traverse_xiso(int in_xiso, xoff_t in_dir_start, uint16_t entry_offset, char*
12631266 if (!err ) err = process_node (in_xiso , node , in_path , in_mode , (in_mode == k_generate_avl ) ? & avl -> subdirectory : nil );
12641267
12651268 // Free memory before recurring
1266- if (node -> filename ) free (node -> filename );
1267- if (node ) free (node );
1269+ if (node ) {
1270+ if (node -> filename ) free (node -> filename );
1271+ free (node );
1272+ }
12681273
12691274 // Repeat on left node
12701275 if (!err && l_offset ) {
0 commit comments