[libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple: Initialize V4L2DeviceFormat before use
Kieran Bingham
kieran.bingham at ideasonboard.com
Wed Oct 21 15:31:10 CEST 2020
Hrm,
On 21/10/2020 14:13, Jacopo Mondi wrote:
> Hi Laurent,
>
> On Wed, Oct 21, 2020 at 05:47:44AM +0300, Laurent Pinchart wrote:
>> The V4L2DeviceFormat has no default constructor. Zero it before use when
>
> Isn't it implicitly generated by the compiler ?
>
>> setting formats. Failure to do so leaves the planes uninitialized,
>> potentially causing memory corruption.
>>
>
> If not, isn't it better to add it in the class ?
Hrm, when I read the patch before, I assumed it was because it was just
a struct or such. Ok - so it's not a complicated class but ...
But indeed, this is marked as a class - so construction surely is suited
to the constructor?
--
Kieran
>
> Thanks
> j
>
>> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
>> ---
>> src/libcamera/pipeline/simple/converter.cpp | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp
>> index b4ee021f6210..b3705abcd626 100644
>> --- a/src/libcamera/pipeline/simple/converter.cpp
>> +++ b/src/libcamera/pipeline/simple/converter.cpp
>> @@ -72,7 +72,7 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)
>> * Set the format on the input side (V4L2 output) of the converter to
>> * enumerate the conversion capabilities on its output (V4L2 capture).
>> */
>> - V4L2DeviceFormat format;
>> + V4L2DeviceFormat format = {};
>> format.fourcc = m2m_->output()->toV4L2PixelFormat(input);
>> format.size = { 1, 1 };
>>
>> @@ -103,7 +103,7 @@ SizeRange SimpleConverter::sizes(const Size &input)
>> * Set the size on the input side (V4L2 output) of the converter to
>> * enumerate the scaling capabilities on its output (V4L2 capture).
>> */
>> - V4L2DeviceFormat format;
>> + V4L2DeviceFormat format = {};
>> format.fourcc = V4L2PixelFormat();
>> format.size = input;
>>
>> @@ -142,7 +142,7 @@ SizeRange SimpleConverter::sizes(const Size &input)
>> int SimpleConverter::configure(PixelFormat inputFormat, const Size &inputSize,
>> StreamConfiguration *cfg)
>> {
>> - V4L2DeviceFormat format;
>> + V4L2DeviceFormat format = {};
>> int ret;
>>
>> V4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);
>> --
>> Regards,
>>
>> Laurent Pinchart
>>
>> _______________________________________________
>> libcamera-devel mailing list
>> libcamera-devel at lists.libcamera.org
>> https://lists.libcamera.org/listinfo/libcamera-devel
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
>
--
Regards
--
Kieran
More information about the libcamera-devel
mailing list