History

img_format: prevent an offset >= MP_MAX_PLANES into bpp

Addresses the warning: "writing 1 byte into a region of size 0"

Mike Will committed 2 years ago

Commit acc69e01 parent e3f426a1 file · +2 −1Browse files

Unified · Split

video/img_format.c+2−1
@@ -399,7 +399,8 @@ fail: · 398 unmodified lines
399399 for (int n = 0; n < 4; n++)
400400 desc->comps[n] = (struct mp_imgfmt_comp_desc){0};
401401 // Average bit size fallback.
402− desc->num_planes = av_pix_fmt_count_planes(fmt);
402+ int num_planes = av_pix_fmt_count_planes(fmt);
403+ desc->num_planes = MPCLAMP(num_planes, 0, MP_MAX_PLANES);
403404 for (int p = 0; p < desc->num_planes; p++) {
404405 int ls = av_image_get_linesize(fmt, 256, p);
405406 desc->bpp[p] = ls > 0 ? ls * 8 / 256 : 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t