Skip to content

Commit

Permalink
convert: Crash fixing while using camera
Browse files Browse the repository at this point in the history
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
  • Loading branch information
ssrlive authored and mchehab committed May 29, 2022
1 parent b5bcc1b commit 8c9b148
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions zbar/convert.c
Expand Up @@ -1125,32 +1125,36 @@ int _zbar_best_format(uint32_t src, uint32_t *dst, const uint32_t *dsts)

int zbar_negotiate_format(zbar_video_t *vdo, zbar_window_t *win)
{
static const uint32_t y800[2] = { fourcc('Y','8','0','0'), 0 };
errinfo_t *errdst;
const uint32_t *srcs, *dsts;
unsigned min_cost = -1;
uint32_t min_fmt = 0;
const uint32_t *fmt;

if (!vdo && !win)
if (!vdo)
return (0);

(void)window_lock(win);
if (win)
(void)window_lock(win);

errdst = &vdo->err;
if (verify_format_sort()) {
(void)window_unlock(win);
if (win)
(void)window_unlock(win);
return (err_capture(errdst, SEV_FATAL, ZBAR_ERR_INTERNAL, __func__,
"image format list is not sorted!?"));
}

if (!vdo->format || !win->formats) {
(void)window_unlock(win);
if (!vdo->formats || (win && !win->formats)) {
if (win)
(void)window_unlock(win);
return (err_capture(errdst, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__,
"no input or output formats available"));
}

srcs = vdo->formats;
dsts = win->formats;
dsts = (win) ? win->formats : y800;

for (fmt = _zbar_formats; *fmt; fmt++) {
/* only consider formats supported by video device */
Expand Down Expand Up @@ -1180,7 +1184,7 @@ int zbar_negotiate_format(zbar_video_t *vdo, zbar_window_t *win)
vdo->emu_formats = NULL;

srcs = vdo->formats;
dsts = win->formats;
dsts = (win) ? win->formats : y800;

/*
* Use the same cost algorithm to select emulated formats.
Expand Down Expand Up @@ -1212,7 +1216,8 @@ int zbar_negotiate_format(zbar_video_t *vdo, zbar_window_t *win)
}
}

(void)window_unlock(win);
if (win)
(void)window_unlock(win);

if (!min_fmt)
return (err_capture(errdst, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__,
Expand Down

0 comments on commit 8c9b148

Please sign in to comment.