justdan96 / tsMuxer

tsMuxer is a transport stream muxer for remuxing/muxing elementary streams, EVO/VOB/MPG, MKV/MKA, MP4/MOV, TS, M2TS to TS to M2TS. Supported video codecs H.264/AVC, H.265/HEVC, VC-1, MPEG2. Supported audio codecs AAC, AC3 / E-AC3(DD+), DTS/ DTS-HD.
Apache License 2.0
849 stars 144 forks source link

cppcheck error - real or false? #610

Open Randrianasulu opened 2 years ago

Randrianasulu commented 2 years ago
38/77 files checked 35% done
Checking tsMuxer/matroskaDemuxer.cpp ...
tsMuxer/matroskaDemuxer.cpp:1935:5: error: Using 'memset' on struct that contains a 'std::vector'. [memsetClass]
    memset(track, 0, MAX_TRACK_SIZE);
    ^
39/77 files checked 40% done

myself not real programmer, so I can't say if this warning real / harmful or false.

justdan96 commented 2 years ago

I think we'd have to check the initialisation, but thanks for reporting. Perhaps if it is a real issue we can include cppcheck in our PR checks to avoid similar issues in the future.

jcdr428 commented 2 years ago

Also reported by clang tidy regarding track:

C:\Users\jcder\Source\Repos\tsMuxer-master\tsMuxer\matroskaDemuxer.cpp(1944,16): warning G00478196: Potential leak of memory pointed to by 'track' [clang-analyzer-cplusplus.NewDeleteLeaks]
        return res;
               ^
C:\Users\jcder\Source\Repos\tsMuxer-master\tsMuxer\matroskaDemuxer.cpp:1934:30: note: Memory is allocated
    track = (MatroskaTrack *)new char[MAX_TRACK_SIZE];
                             ^
C:\Users\jcder\Source\Repos\tsMuxer-master\tsMuxer\matroskaDemuxer.cpp:1938:9: note: Assuming 'MAX_STREAMS' is >= field 'num_tracks'
    if (num_tracks > MAX_STREAMS)
        ^
C:\Users\jcder\Source\Repos\tsMuxer-master\tsMuxer\matroskaDemuxer.cpp:1938:5: note: Taking false branch
    if (num_tracks > MAX_STREAMS)
    ^
C:\Users\jcder\Source\Repos\tsMuxer-master\tsMuxer\matroskaDemuxer.cpp:1943:5: note: Taking true branch
    if ((res = ebml_read_master(&id)) < 0)
    ^
C:\Users\jcder\Source\Repos\tsMuxer-master\tsMuxer\matroskaDemuxer.cpp:1944:16: note: Potential leak of memory pointed to by 'track'
        return res;