[mythtv] Invalid pointer de-ref in NuppelVideoRecorder.cpp

Mark Kendall mark.kendall at gmail.com
Tue Dec 3 08:08:41 UTC 2019


On Tue, 3 Dec 2019 at 06:37, David Hampton <mythtv at love2code.net> wrote:
>
> Hi Mark,
>
> The clang-tidy  program is spitting out a possible null-pointer de-
> reference in NuppelVideoRecorder.cpp, function BufferIt, line 1846.
>
>     memcpy(videobuffer[act]->buffer, buf, len);
>
> Its complaining about the "buf" variable.  Backing up, this is called
> from DoV4L2() on line 1567 or line 1577, which both pass the
> output_buffer variable to BufferIt.
>
>      BufferIt(output_buffer, m_video_buffer_size);
>
> Backing up a little further, the output_buffer pointer is assigned at
> line 1438 inside of an "if" statement, a conditional that doesn't
> control the calls to BufferIt.  If this conditional is false,
> output_buffer is never assigned, and is still nullptr when passed to
> BufferIt.

David

I'm not familiar with NuppelVideoRecorder  (though IMHO it should
nuked/removed/deleted as soon as possible!).

Looking at the code, buffer_output is only ever set and used when the
v4l2 pixel format is YUYV or UYVY. So the code should be safe but you
could silence the warning by adding an extra check for '&&
output_buffer' to the end of lines 1559 and 1569 - if that makes
sense.

Regards
Mark


More information about the mythtv-dev mailing list