aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-11-08 13:36:01 +0000
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-11-09 09:12:09 +0000
commit731a651f202374ec20e963d76577528ab01df124 (patch)
tree37902f04201426bbbf31be6b79a254735b4a1765
parent6ead632c5d4de09e480e086f730b552b7ad81a1b (diff)
downloadv4l-utils-731a651f202374ec20e963d76577528ab01df124.tar.gz
v4l2grab: avoid the risc of having sizeimage == 0
In the eventual case where sizeimage is zero, userptr will fail. So, add a default. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-rw-r--r--contrib/test/v4l2grab.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/contrib/test/v4l2grab.c b/contrib/test/v4l2grab.c
index de5fd8c0..eb8ba6c5 100644
--- a/contrib/test/v4l2grab.c
+++ b/contrib/test/v4l2grab.c
@@ -674,6 +674,10 @@ static int userptr_capture(int fd, int n_frames, unsigned char *out_buf, char *o
exit(EXIT_FAILURE);
}
+ /* Some compressed formats could return zero */
+ if (!fmt->fmt.pix.sizeimage)
+ fmt->fmt.pix.sizeimage = fmt->fmt.pix.width * fmt->fmt.pix.height * 3;
+
for (n_buffers = 0; n_buffers < req.count; ++n_buffers) {
buffers[n_buffers].length = fmt->fmt.pix.sizeimage;
buffers[n_buffers].start = calloc(1, fmt->fmt.pix.sizeimage);