@@ -812,7 +812,7 @@ int main( int argc, char **argv ) {
812
812
if ( ! err && stat ( buf , & sb ) != -1 ) misc_err ( "%s already exists, cannot rewrite %s" , buf , argv [ i ] );
813
813
if ( ! err && rename ( argv [ i ], buf ) == -1 ) misc_err ( "cannot rename %s to %s" , argv [ i ], buf );
814
814
815
- if ( err ) { err = 0 ; free ( buf ); continue ; }
815
+ if ( err ) { err = 0 ; if ( buf ) free ( buf ); continue ; }
816
816
}
817
817
if ( ! err ) err = decode_xiso ( buf , path , k_rewrite , & new_iso_path );
818
818
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
1022
1022
if ( ! err && ( buf = (char * ) malloc ( n = max ( READWRITE_BUFFER_SIZE , XISO_HEADER_OFFSET ) ) ) == nil ) mem_err ();
1023
1023
if ( ! err ) {
1024
1024
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
+ }
1027
1030
}
1028
1031
if ( ! err ) {
1029
1032
memset ( buf , 0 , n );
@@ -1090,7 +1093,7 @@ int create_xiso( char *in_root_directory, char *in_output_directory, dir_node_av
1090
1093
1091
1094
if ( xiso != -1 ) {
1092
1095
close ( xiso );
1093
- if ( err ) unlink ( xiso_path );
1096
+ if (err && xiso_path ) unlink (xiso_path );
1094
1097
}
1095
1098
1096
1099
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*
1219
1222
}
1220
1223
1221
1224
// 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 ();
1223
1226
if (!err && read (in_xiso , & r_offset , XISO_TABLE_OFFSET_SIZE ) != XISO_TABLE_OFFSET_SIZE ) read_err ();
1224
1227
if (!err && read (in_xiso , & node -> start_sector , XISO_SECTOR_OFFSET_SIZE ) != XISO_SECTOR_OFFSET_SIZE ) read_err ();
1225
1228
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*
1263
1266
if (!err ) err = process_node (in_xiso , node , in_path , in_mode , (in_mode == k_generate_avl ) ? & avl -> subdirectory : nil );
1264
1267
1265
1268
// 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
+ }
1268
1273
1269
1274
// Repeat on left node
1270
1275
if (!err && l_offset ) {
0 commit comments