Skip to content

Commit 62244ed

Browse files
quariumcmassiot
authored andcommitted
Fix potential zero-length VLA
1 parent 875f23d commit 62244ed

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lib/upipe-ts/upipe_ts_pmt_decoder.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,8 @@ static int upipe_ts_pmtd_parse_descs(struct upipe *upipe,
635635
const uint8_t *desc;
636636
int j = 0;
637637

638-
uint8_t descl_copy[desclength];
638+
/* desclength can be zero and VLA must be greater than zero */
639+
uint8_t descl_copy[desclength + 1];
639640
uint16_t copy_len = 0;
640641

641642
/* cast needed because biTStream expects an uint8_t * (but doesn't write

lib/upipe/ubuf_pic_mem.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,9 @@ static struct ubuf *ubuf_pic_mem_alloc(struct ubuf_mgr *mgr,
146146

147147
size_t hmsize = hsize / pic_mgr->common_mgr.macropixel;
148148
size_t buffer_size = 0;
149-
size_t plane_sizes[pic_mgr->common_mgr.nb_planes];
150-
size_t strides[pic_mgr->common_mgr.nb_planes];
149+
/* nb_planes can be zero and VLA must be greater than zero */
150+
size_t plane_sizes[pic_mgr->common_mgr.nb_planes + 1];
151+
size_t strides[pic_mgr->common_mgr.nb_planes + 1];
151152
for (uint8_t plane = 0; plane < pic_mgr->common_mgr.nb_planes; plane++) {
152153
size_t align = 0;
153154
if (pic_mgr->align &&

lib/upipe/ubuf_sound_mem.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ static struct ubuf *ubuf_sound_mem_alloc(struct ubuf_mgr *mgr,
127127
}
128128

129129
size_t buffer_size = 0;
130-
size_t plane_sizes[sound_mgr->common_mgr.nb_planes];
130+
/* nb_planes can be zero and VLA must be greater than zero */
131+
size_t plane_sizes[sound_mgr->common_mgr.nb_planes + 1];
131132
for (uint8_t plane = 0; plane < sound_mgr->common_mgr.nb_planes; plane++) {
132133
size_t align = 0;
133134
size_t plane_size;

0 commit comments

Comments
 (0)