Add fbounds-safety annotations for palette.

Reasoning:

The `palette` parameter in `GetColorPalette` (src/utils/palette.c:100)
was annotated with `WEBP_COUNTED_BY_OR_NULL(MAX_PALETTE_SIZE)` to fix
an array subscript error at src/utils/palette.c:146. This annotation
reflects the function's contract, documented in src/utils/palette.h,
which states that if `palette` is not NULL, it must point to memory
allocated for at least `MAX_PALETTE_SIZE` elements. To make
`MAX_PALETTE_SIZE` visible, `src/webp/format_constants.h` was included
in `src/utils/palette.h`. Consequently, the wrapper function
`WebPGetColorPalette` (src/utils/utils.c:273) and its declaration in
`src/utils/utils.h` were also annotated similarly, requiring the
inclusion of `src/webp/format_constants.h` in `src/utils/utils.h` as
well. This resolved a compilation error caused by the type mismatch
when calling the annotated `GetColorPalette` from `WebPGetColorPalette`.

Bug: 432511821
Change-Id: Iceebf2facf9558dd49889f056f028d9a3fb22d41
This commit is contained in:
Arman Hasanzadeh
2025-08-19 11:52:40 -07:00
parent 9b3fc5f5e8
commit 69b9b8525e
4 changed files with 13 additions and 5 deletions

View File

@@ -271,7 +271,9 @@ void WebPCopyPixels(const WebPPicture* const src, WebPPicture* const dst) {
//------------------------------------------------------------------------------
int WebPGetColorPalette(const WebPPicture* const pic, uint32_t* const palette) {
int WebPGetColorPalette(
const WebPPicture* const pic,
uint32_t* const WEBP_COUNTED_BY_OR_NULL(MAX_PALETTE_SIZE) palette) {
return GetColorPalette(pic, palette);
}