@@ -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 );
@@ -1087,7 +1090,7 @@ int create_xiso( char *in_root_directory, char *in_output_directory, dir_node_av
1087
1090
1088
1091
if ( xiso != -1 ) {
1089
1092
close ( xiso );
1090
- if ( err ) unlink ( xiso_path );
1093
+ if (err && xiso_path ) unlink (xiso_path );
1091
1094
}
1092
1095
1093
1096
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*
1216
1219
}
1217
1220
1218
1221
// 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 ();
1220
1223
if (!err && read (in_xiso , & r_offset , XISO_TABLE_OFFSET_SIZE ) != XISO_TABLE_OFFSET_SIZE ) read_err ();
1221
1224
if (!err && read (in_xiso , & node -> start_sector , XISO_SECTOR_OFFSET_SIZE ) != XISO_SECTOR_OFFSET_SIZE ) read_err ();
1222
1225
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*
1260
1263
if (!err ) err = process_node (in_xiso , node , in_path , in_mode , (in_mode == k_generate_avl ) ? & avl -> subdirectory : nil );
1261
1264
1262
1265
// 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
+ }
1265
1270
1266
1271
// Repeat on left node
1267
1272
if (!err && l_offset ) {
0 commit comments