diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2017-08-11 14:42:37 +0200 |
---|---|---|
committer | Hans Verkuil <hans.verkuil@cisco.com> | 2017-08-11 14:42:37 +0200 |
commit | 5a67da05fded64b5f678033c16196799e134c62c (patch) | |
tree | 27660c2fa0ddc813889869198f1898f62e7cb06d | |
parent | 7a172d76b5eb606d06f396dc4bce9b71c0b78c03 (diff) |
v4l2-ctl: qc.nr_of_dims is 0 for strings, check this
The string type doesn't use dimensions, so nr_of_dims is 0 which
means that using nr_of_dims - 1 as an index in an array is a bad
idea.
Put that code under an 'if (qc.nr_of_dims)' to avoid a bus error.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r-- | utils/v4l2-ctl/v4l2-ctl-common.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp index 4ca1b834..60624750 100644 --- a/utils/v4l2-ctl/v4l2-ctl-common.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp @@ -844,11 +844,13 @@ void common_set(int fd) if (fill_subset(qc, subset)) return; - divide[qc.nr_of_dims - 1] = 1; - for (d = 0; d < qc.nr_of_dims - 1; d++) { - divide[d] = qc.dims[d + 1]; - for (i = 0; i < d; i++) - divide[i] *= divide[d]; + if (qc.nr_of_dims) { + divide[qc.nr_of_dims - 1] = 1; + for (d = 0; d < qc.nr_of_dims - 1; d++) { + divide[d] = qc.dims[d + 1]; + for (i = 0; i < d; i++) + divide[i] *= divide[d]; + } } |