@@ -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 );
@@ -1088,7 +1091,7 @@ int create_xiso( char *in_root_directory, char *in_output_directory, dir_node_av
1088
1091
1089
1092
if ( xiso != -1 ) {
1090
1093
close ( xiso );
1091
- if ( err ) unlink ( xiso_path );
1094
+ if (err && xiso_path ) unlink (xiso_path );
1092
1095
}
1093
1096
1094
1097
if ( root .filename ) free ( root .filename );
@@ -1217,7 +1220,7 @@ int traverse_xiso(int in_xiso, xoff_t in_dir_start, uint16_t entry_offset, char*
1217
1220
}
1218
1221
1219
1222
// Read node
1220
- if (!err ) if (! (node = calloc (1 , sizeof (dir_node )))) mem_err ();
1223
+ if (!err ) if ((node = calloc (1 , sizeof (dir_node ))) == nil ) mem_err ();
1221
1224
if (!err && read (in_xiso , & r_offset , XISO_TABLE_OFFSET_SIZE ) != XISO_TABLE_OFFSET_SIZE ) read_err ();
1222
1225
if (!err && read (in_xiso , & node -> start_sector , XISO_SECTOR_OFFSET_SIZE ) != XISO_SECTOR_OFFSET_SIZE ) read_err ();
1223
1226
if (!err && read (in_xiso , & node -> file_size , XISO_FILESIZE_SIZE ) != XISO_FILESIZE_SIZE ) read_err ();
@@ -1261,8 +1264,10 @@ int traverse_xiso(int in_xiso, xoff_t in_dir_start, uint16_t entry_offset, char*
1261
1264
if (!err ) err = process_node (in_xiso , node , in_path , in_mode , (in_mode == k_generate_avl ) ? & avl -> subdirectory : nil );
1262
1265
1263
1266
// Free memory before recurring
1264
- if (node -> filename ) free (node -> filename );
1265
- if (node ) free (node );
1267
+ if (node ) {
1268
+ if (node -> filename ) free (node -> filename );
1269
+ free (node );
1270
+ }
1266
1271
1267
1272
// Repeat on left node
1268
1273
if (!err && l_offset ) {
0 commit comments