From 185557344ae79890d4acbbf5972972d20af1dd05 Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Thu, 17 Mar 2011 00:23:36 -0700 Subject: [PATCH] Set bounds from the array when iterating mmaps. The mmap allocation code in vp8_dx_iface.c was inconsistent. The static array vp8_mem_req_segs defines two descriptors, but only the first is real. The second is a sentinel and isn't actually allocated, so vpx_codec_alg_priv is declared with mmaps[NELEMENTS(vp8_mem_req_segs)-1]. Some functions use this reduced upper bound when iterating though the mmap array, but these two functions did not. Instead, this commit calls NELEMENTS(...->mmaps) to directly query the bounds of the dereferenced array. This fixes an array-bounds warning from gcc 4.6 on vp8_xma_set_mmap. Change-Id: I918e2721b401d134c1a9764c978912bdb3188be1 --- vp8/vp8_dx_iface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vp8/vp8_dx_iface.c b/vp8/vp8_dx_iface.c index 4f64f0d..99657e0 100644 --- a/vp8/vp8_dx_iface.c +++ b/vp8/vp8_dx_iface.c @@ -168,7 +168,7 @@ static void *mmap_lkup(vpx_codec_alg_priv_t *ctx, unsigned int id) { int i; - for (i = 0; i < NELEMENTS(vp8_mem_req_segs); i++) + for (i = 0; i < NELEMENTS(ctx->mmaps); i++) if (ctx->mmaps[i].id == id) return ctx->mmaps[i].base; @@ -525,7 +525,7 @@ static vpx_codec_err_t vp8_xma_set_mmap(vpx_codec_ctx_t *ctx, if (!res && ctx->priv->alg_priv) { - for (i = 0; i < NELEMENTS(vp8_mem_req_segs); i++) + for (i = 0; i < NELEMENTS(ctx->priv->alg_priv->mmaps); i++) { if (ctx->priv->alg_priv->mmaps[i].id == mmap->id) if (!ctx->priv->alg_priv->mmaps[i].base) -- 2.7.4