tsMuxer icon indicating copy to clipboard operation
tsMuxer copied to clipboard

cppcheck error - real or false?

Open Randrianasulu opened this issue 3 years ago • 2 comments

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.

Randrianasulu avatar May 30 '22 22:05 Randrianasulu

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.

justdan96 avatar May 31 '22 08:05 justdan96

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;

jcdr428 avatar Jun 01 '22 06:06 jcdr428