This is an automated email from the ASF dual-hosted git repository.
GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 0949c4c9d examples/fb: Cast yres to size_t before computing framesize
0949c4c9d is described below
commit 0949c4c9de96be46b4cdeaebd094a59ab8da1c5a
Author: jianglianfang <[email protected]>
AuthorDate: Fri May 15 14:22:56 2026 +0800
examples/fb: Cast yres to size_t before computing framesize
vinfo.yres and pinfo.stride are both 16-bit, so their product is
computed in int and can overflow before being assigned to the size_t
framesize. Cast yres to size_t so the multiplication is done in size_t.
Reported by Coverity (sign extension).
Signed-off-by: jianglianfang <[email protected]>
---
examples/fb/fb_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/fb/fb_main.c b/examples/fb/fb_main.c
index 627be1d00..65e7ebdd9 100644
--- a/examples/fb/fb_main.c
+++ b/examples/fb/fb_main.c
@@ -252,7 +252,7 @@ static int fb_init_mem2(FAR struct fb_state_s *state)
/* Use virtual offset = fblen = stride * yres */
- framesize = state->vinfo.yres * state->pinfo.stride;
+ framesize = (size_t)state->vinfo.yres * state->pinfo.stride;
offset = framesize;
state->mem2_yoffset = state->vinfo.yres;