[vlc-commits] [Git][videolan/vlc][master] test: decoder: fix fmt_in leaks

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Sep 16 08:21:12 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
8e50335e by Thomas Guillem at 2024-09-16T07:51:16+00:00
test: decoder: fix fmt_in leaks

Regression from 08b24866dc443c30df8f9d5ee4f7e2045bf62956

```
==1851678==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 12 byte(s) in 1 object(s) allocated from:
    #0 0x55ab52726322 in malloc (/home/tom/work/git/vlc/build-fuzzer-asan/test/vlc-demux-dec-libfuzzer+0xf5322) (BuildId: e44569652285bf8bd3c1b21a8e857c36a2185e73)
    #1 0x7fac6d4ed649 in es_format_Copy /home/tom/work/git/vlc/build-fuzzer-asan/src/../../src/misc/es_format.c:350:24
    #2 0x7fac6d3c2fc9 in decoder_Init /home/tom/work/git/vlc/build-fuzzer-asan/src/../../src/input/decoder_helpers.c:49:5
    #3 0x55ab52764362 in decoder_load /home/tom/work/git/vlc/build-fuzzer-asan/test/../../test/src/input/decoder.c:103:5
    #4 0x55ab52764362 in test_decoder_create /home/tom/work/git/vlc/build-fuzzer-asan/test/../../test/src/input/decoder.c:196:9
    #5 0x55ab52762fe5 in EsOutAdd /home/tom/work/git/vlc/build-fuzzer-asan/test/../../test/src/input/demux-run.c:86:19
    #6 0x7fac59c9d0a4 in es_out_Add /home/tom/work/git/vlc/build-fuzzer-asan/modules/../../include/vlc_es_out.h:144:12
    #7 0x7fac59c9d0a4 in avformat_OpenDemux /home/tom/work/git/vlc/build-fuzzer-asan/modules/../../modules/demux/avformat/demux.c:702:29
    #8 0x7fac6d3c5d0a in demux_Probe /home/tom/work/git/vlc/build-fuzzer-asan/src/../../src/input/demux.c:112:15
    #9 0x7fac6d368128 in vlc_module_load /home/tom/work/git/vlc/build-fuzzer-asan/src/../../src/modules/modules.c:230:15
    #10 0x7fac6d3c5250 in demux_NewAdvanced /home/tom/work/git/vlc/build-fuzzer-asan/src/../../src/input/demux.c:196:20
    #11 0x7fac6d3c48b3 in demux_New /home/tom/work/git/vlc/build-fuzzer-asan/src/../../src/input/demux.c:77:12
    #12 0x55ab527620d9 in demux_process_stream /home/tom/work/git/vlc/build-fuzzer-asan/test/../../test/src/input/demux-run.c:294:22
    #13 0x55ab52761c03 in LLVMFuzzerTestOneInput /home/tom/work/git/vlc/build-fuzzer-asan/test/../../test/vlc-demux-libfuzzer.c:54:5
    #14 0x55ab52672134 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/tom/work/git/vlc/build-fuzzer-asan/test/vlc-demux-dec-libfuzzer+0x41134) (BuildId: e44569652285bf8bd3c1b21a8e857c36a2185e73)
    #15 0x55ab5265b083 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/home/tom/work/git/vlc/build-fuzzer-asan/test/vlc-demux-dec-libfuzzer+0x2a083) (BuildId: e44569652285bf8bd3c1b21a8e857c36a2185e73)
    #16 0x55ab52660ca6 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/tom/work/git/vlc/build-fuzzer-asan/test/vlc-demux-dec-libfuzzer+0x2fca6) (BuildId: e44569652285bf8bd3c1b21a8e857c36a2185e73)
    #17 0x55ab5268b796 in main (/home/tom/work/git/vlc/build-fuzzer-asan/test/vlc-demux-dec-libfuzzer+0x5a796) (BuildId: e44569652285bf8bd3c1b21a8e857c36a2185e73)
    #18 0x7fac6cf2ddb9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
```

- - - - -


1 changed file:

- test/src/input/decoder.c


Changes:

=====================================
test/src/input/decoder.c
=====================================
@@ -126,15 +126,20 @@ static int decoder_load(decoder_t *decoder, bool is_packetizer,
     return VLC_SUCCESS;
 }
 
-void test_decoder_destroy(decoder_t *decoder)
+static void decoder_destroy_clean(decoder_t *decoder)
 {
     struct decoder_owner *owner = dec_get_owner(decoder);
-
     es_format_Clean(&owner->fmt_in);
-    decoder_Destroy(owner->packetizer);
     decoder_Destroy(decoder);
 }
 
+void test_decoder_destroy(decoder_t *decoder)
+{
+    struct decoder_owner *owner = dec_get_owner(decoder);
+    decoder_destroy_clean(owner->packetizer);
+    decoder_destroy_clean(decoder);
+}
+
 decoder_t *test_decoder_create(vlc_object_t *parent, const es_format_t *fmt)
 {
     assert(parent && fmt);
@@ -144,7 +149,7 @@ decoder_t *test_decoder_create(vlc_object_t *parent, const es_format_t *fmt)
     if (packetizer == NULL || decoder == NULL)
     {
         if (packetizer)
-            vlc_object_delete(packetizer);
+            decoder_destroy_clean(packetizer);
         return NULL;
     }
 
@@ -185,22 +190,22 @@ decoder_t *test_decoder_create(vlc_object_t *parent, const es_format_t *fmt)
             decoder->cbs = &dec_spu_cbs;
             break;
         default:
-            vlc_object_delete(packetizer);
-            vlc_object_delete(decoder);
+            decoder_destroy_clean(packetizer);
+            decoder_destroy_clean(decoder);
             return NULL;
     }
 
     if (decoder_load(packetizer, true, fmt) != VLC_SUCCESS)
     {
-        vlc_object_delete(packetizer);
-        vlc_object_delete(decoder);
+        decoder_destroy_clean(packetizer);
+        decoder_destroy_clean(decoder);
         return NULL;
     }
 
     if (decoder_load(decoder, false, &packetizer->fmt_out) != VLC_SUCCESS)
     {
-        decoder_Destroy(packetizer);
-        vlc_object_delete(decoder);
+        decoder_destroy_clean(packetizer);
+        decoder_destroy_clean(decoder);
         return NULL;
     }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8e50335ec7b675ef50d507639ed1fa3959ebe4fd

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8e50335ec7b675ef50d507639ed1fa3959ebe4fd
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