Skip to content

cvtColor should check for even dimensions in COLOR_YUV2RGB_* #21035

@vrabaud

Description

@vrabaud
System information (version)
  • OpenCV => 4.5.4
  • Operating System / Platform => Ubuntu
  • Compiler => clang
Detailed description

When using cvtColor with COLOR_YUV2BGR_UYVY (or any COLOR_YUV2BGR_*), the code assumes the width to be even while it should be checked for it (probably something to add to CvtHelper).
The assumption is made here:

for (; i < 2 * width; i += 4, row += dcn*2)

(i+=4 is done while we do not even know if 2*width is a multiple of 4).

Steps to reproduce

Use a simple 1x1 CV8U_C2 matrix and the code will run but will read data outside the matrix (which should be 1x2).

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions