summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2010-07-24 22:09:09 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2010-07-24 22:09:09 +0000
commit1d9029af0d07cc307f8e90300ad41281e0c3c7e6 (patch)
tree2dd745f9ba1a65865aa942eaff22f7c21c362168
parentc8e71f3789907ff9efc1e1128f6debe77671c639 (diff)
do not add the same size twice, and do not fall of the end of
the frame sizes array. reported/tested mglocker
-rw-r--r--app/video/video.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/video/video.c b/app/video/video.c
index 05a08ca86..cc4dbba0e 100644
--- a/app/video/video.c
+++ b/app/video/video.c
@@ -764,7 +764,7 @@ dev_get_sizes(struct video *vid)
d->sizes[0].w = sizes[0].w;
d->sizes[0].h = sizes[0].h;
d->nsizes = 1;
- for (i = 0; i < nsizes; i++) {
+ for (i = 1; i < nsizes; i++) {
for (j = 0; j < d->nsizes; j++) {
if (sizes[i].w < d->sizes[j].w)
break;
@@ -1028,9 +1028,12 @@ choose_size(struct video *vid)
}
if (vid->mode & M_IN_DEV) {
i = 0;
- while (d->sizes[i].h <= vid->height &&
+ while (i < d->nsizes &&
+ d->sizes[i].h <= vid->height &&
d->sizes[i].w <= vid->width)
i++;
+ if (i >= d->nsizes)
+ i = d->nsizes - 1;
if (i > 0 && (d->sizes[i].h > vid->height ||
d->sizes[i].w > vid->width))
i--;