Commit c25b144c authored by lefort's avatar lefort
Browse files

Memory leak corrected.

parent 555ab26f
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -1311,54 +1311,60 @@ char *create_hrtf_fastconv( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG

        if ( fread( &hrtf_identifier, sizeof( char ), 8, input_fastconv_bin_file ) != 8 )
        {
            fprintf( stderr, "Reading of the mixer_conv hrtf failed!\n\n" );
            fprintf( stderr, "Reading of the fastconv hrtf failed!\n\n" );
            fclose( input_fastconv_bin_file );
            free( fastconv_hrtf );
            free(full_in_fastconv_path);
            *hrtf_size = -1;
            return NULL;
        }

        if ( fread( &hrtf_total_file_size, sizeof( int32_t ), 1, input_fastconv_bin_file ) != 1 )
        {
            fprintf( stderr, "Reading of the mixer_conv hrtf failed!\n\n" );
            fprintf( stderr, "Reading of the fastconv hrtf failed!\n\n" );
            fclose( input_fastconv_bin_file );
            free( fastconv_hrtf );
            free(full_in_fastconv_path);
            *hrtf_size = -1;
            return NULL;
        }

        if ( hrtf_total_file_size != fastconv_hrtf_data_size )
        {
            fprintf( stderr, "Reading of the mixer_conv hrtf failed!\n\n" );
            fprintf( stderr, "Reading of the fastconv hrtf failed!\n\n" );
            fclose( input_fastconv_bin_file );
            free( fastconv_hrtf );
            free(full_in_fastconv_path);
            *hrtf_size = -1;
            return NULL;
        }

        if ( fread( &nbHrft, sizeof( int16_t ), 1, input_fastconv_bin_file ) != 1 )
        {
            fprintf( stderr, "Reading of the mixer_conv hrtf failed!\n\n" );
            fprintf( stderr, "Reading of the fastconv hrtf failed!\n\n" );
            fclose( input_fastconv_bin_file );
            free( fastconv_hrtf );
            free(full_in_fastconv_path);
            *hrtf_size = -1;
            return NULL;
        }

        if ( fread( &hrtf_data_size, sizeof( int32_t ), 1, input_fastconv_bin_file ) != 1 )
        {
            fprintf( stderr, "Reading of the mixer_conv hrtf failed!\n\n" );
            fprintf( stderr, "Reading of the fastconv hrtf failed!\n\n" );
            fclose( input_fastconv_bin_file );
            free( fastconv_hrtf );
            free(full_in_fastconv_path);
            *hrtf_size = -1;
            return NULL;
        }

        if ( hrtf_data_size != fastconv_hrtf_data_size - nbHrft * sizeof( ivas_hrtfs_header_t ) - ( sizeof( int32_t ) * 2 + sizeof( int16_t ) + sizeof( char ) * 8 ) )
        {
            fprintf( stderr, "Reading of the mixer_conv hrtf failed!\n\n" );
            fprintf( stderr, "Reading of the fastconv hrtf failed!\n\n" );
            fclose( input_fastconv_bin_file );
            free( fastconv_hrtf );
            free(full_in_fastconv_path);
            *hrtf_size = -1;
            return NULL;
        }
@@ -1367,9 +1373,10 @@ char *create_hrtf_fastconv( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG
        {
            if ( fread( &hrtf_header, sizeof( ivas_hrtfs_header_t ), 1, input_fastconv_bin_file ) != 1 )
            {
                fprintf( stderr, "Reading of the mixer_conv hrtf failed!\n\n" );
                fprintf( stderr, "Reading of the fastconv hrtf failed!\n\n" );
                fclose( input_fastconv_bin_file );
                free( fastconv_hrtf );
                free(full_in_fastconv_path);
                *hrtf_size = -1;
                return NULL;
            }
@@ -1396,6 +1403,7 @@ char *create_hrtf_fastconv( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG
        {
            fprintf( stderr, "Memory allocation for the block failed!\n\n" );
            fclose( input_fastconv_bin_file );
            free(full_in_fastconv_path);
            *hrtf_size = -1;
            return NULL;
        }
@@ -1425,9 +1433,10 @@ char *create_hrtf_fastconv( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG

        if ( fread( fastconv_hrtf_wptr, fastconv_hrtf_data_size, 1, input_fastconv_bin_file ) != 1 )
        {
            fprintf( stderr, "Reading of the mixer_conv hrtf failed!\n\n" );
            fprintf( stderr, "Reading of the fastconv hrtf failed!\n\n" );
            fclose( input_fastconv_bin_file );
            free( fastconv_hrtf );
            free(full_in_fastconv_path);
            *hrtf_size = -1;
            return NULL;
        }
@@ -1439,6 +1448,7 @@ char *create_hrtf_fastconv( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG
    {
        fprintf( stderr, "Opening of file %s failed!\n\n", full_in_fastconv_path );
        *hrtf_size = -1;
        free(full_in_fastconv_path);
        return NULL;
    }