[vlc-commits] [Git][videolan/vlc][master] 2 commits: transcode: audio: fix `encoder_test` memory leak

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Mon Sep 26 14:56:30 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
4c530717 by Alaric Senat at 2022-09-26T14:28:50+00:00
transcode: audio: fix `encoder_test` memory leak

By using the new `vlc_encoder_Delete` call that closes the module
properly.

Caught with asan:
Direct leak of 104 byte(s) in 1 object(s) allocated from:
    #0 0x7ff80d66891f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
    #1 0x7ff7f75daa14 in OpenEncoder ../../modules/codec/flac.c:809
    #2 0x7ff80c8a946f in generic_start ../../src/modules/modules.c:275
    #3 0x7ff80c8a9083 in vlc_module_load ../../src/modules/modules.c:243
    #4 0x7ff80c8a95a5 in module_need ../../src/modules/modules.c:286
    #5 0x7ff800fce802 in transcode_encoder_audio_test ../../modules/stream_out/transcode/encoder/audio.c:175
    #6 0x7ff800fcb583 in transcode_encoder_test ../../modules/stream_out/transcode/encoder/encoder.c:246
    #7 0x7ff800fe0484 in transcode_audio_init ../../modules/stream_out/transcode/audio.c:168
    #8 0x7ff800fc6995 in Add ../../modules/stream_out/transcode/transcode.c:631
    #9 0x7ff80cc3fe5a in sout_StreamIdAdd ../../src/stream_output/stream_output.c:699
    #10 0x7ff80cc39913 in sout_InputNew ../../src/stream_output/stream_output.c:134
    #11 0x7ff80c9405a5 in DecoderThread_ProcessSout ../../src/input/decoder.c:1006
    #12 0x7ff80c94685d in DecoderThread_ProcessInput ../../src/input/decoder.c:1518
    #13 0x7ff80c95142d in vlc_input_decoder_Decode ../../src/input/decoder.c:2295
    #14 0x7ff80c995b52 in EsOutSend ../../src/input/es_out.c:3017
    #15 0x7ff80c9ad499 in es_out_Send ../../include/vlc_es_out.h:161
    #16 0x7ff80c9beca6 in CmdExecuteSend ../../src/input/es_out_timeshift.c:1484
    #17 0x7ff80c9af854 in Send ../../src/input/es_out_timeshift.c:486
    #18 0x7ff7ffd8eab2 in es_out_Send ../../include/vlc_es_out.h:161
    #19 0x7ff7ffd9db18 in Demux ../../modules/demux/mpeg/es.c:400
    #20 0x7ff80c960edd in demux_Demux ../../src/input/demux.c:212
    #21 0x7ff80c9d0abb in MainLoopDemux ../../src/input/input.c:498
    #22 0x7ff80c9d30a6 in MainLoop ../../src/input/input.c:645
    #23 0x7ff80c9d024b in Run ../../src/input/input.c:428
    #24 0x7ff80b66b821 in start_thread (/lib64/libc.so.6+0x9f821)

- - - - -
fe54d2eb by Alaric Senat at 2022-09-26T14:28:50+00:00
transcode: encoder: use `vlc_encoder_Destroy()`

Instead of cleaning the encoder manually.

This fixes some memory leaks due to the `close()` module callback being
forgotten here.

- - - - -


2 changed files:

- modules/stream_out/transcode/encoder/audio.c
- modules/stream_out/transcode/encoder/encoder.c


Changes:

=====================================
modules/stream_out/transcode/encoder/audio.c
=====================================
@@ -180,12 +180,6 @@ int transcode_encoder_audio_test( encoder_t *p_encoder,
                            p_cfg->psz_name ? p_cfg->psz_name : "any",
                            (char *)&p_cfg->i_codec );
     }
-    else
-    {
-        /* Close the encoder.
-         * We'll open it only when we have the first frame. */
-        module_unneed( p_encoder, p_module );
-    }
 
     p_encoder->fmt_in.audio.i_format = p_encoder->fmt_in.i_codec;
 
@@ -194,10 +188,7 @@ int transcode_encoder_audio_test( encoder_t *p_encoder,
     /* copy our requested format */
     es_format_Copy( p_enc_wanted_in, &p_encoder->fmt_in );
 
-    es_format_Clean( &p_encoder->fmt_in );
-    es_format_Clean( &p_encoder->fmt_out );
-
-    vlc_object_delete(p_encoder);
+    vlc_encoder_Destroy( p_encoder );
 
     return p_module != NULL ? VLC_SUCCESS : VLC_EGENERIC;
 }


=====================================
modules/stream_out/transcode/encoder/encoder.c
=====================================
@@ -51,9 +51,8 @@ void transcode_encoder_delete( transcode_encoder_t *p_enc )
             block_ChainRelease( p_enc->p_buffers );
             picture_fifo_Delete( p_enc->pp_pics );
         }
-        es_format_Clean( &p_enc->p_encoder->fmt_in );
-        es_format_Clean( &p_enc->p_encoder->fmt_out );
-        vlc_object_delete(p_enc->p_encoder);
+
+        vlc_encoder_Destroy( p_enc->p_encoder );
     }
     free( p_enc );
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c3af02188c623692d33a703020f65ecf3d18f39e...fe54d2eb257718eebfef0a5fe624771b7fac5bf0

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c3af02188c623692d33a703020f65ecf3d18f39e...fe54d2eb257718eebfef0a5fe624771b7fac5bf0
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list