zephyr/lib
Christoph Winklhofer 061e345972 json: Fix calculation of object size
The calculation of the object size may be incorrect when the size of
a field is smaller than the struct alignment. When such a struct is
used in an array field, the decoded object contains wrong values.

The alignment influences the object size. For example the following
struct has a calculated object size of 8 bytes, however due to
alignment the real size of the struct is 12 bytes:

struct test_bool {
  bool b1; /* offset 0, size 1 */
           /* 3-byte padding */
  int i1;  /* offset 4, size 4 */
  bool b2; /* offset 8, size 1 */
           /* 3-byte padding */
};

This commit changes the object size calculation and computes the size
with the offset and size of the last field in the struct (rounded up
by the struct alignment).

Fixes: #85121
Signed-off-by: Christoph Winklhofer <cj.winklhofer@gmail.com>
2025-04-08 11:44:51 +02:00
..
acpi lib: fix typo in multiple directories 2025-01-28 00:06:18 +01:00
cpp cpp: Add c++ version number 2025-02-10 15:57:26 +00:00
crc lib: crc: add crc8_rohc for CRC-8/ROHC variant calculation 2024-10-09 09:48:00 +02:00
hash
heap kernel: sys_heap: decouple realloc from aligned_realloc 2025-04-01 22:13:04 +02:00
libc libc: add comment to empty sys/cdefs.h file 2025-02-21 15:13:20 +00:00
mem_blocks
net_buf lib: net_buf: remove deprecated net_buf_put() and net_buf_get() functions 2025-03-12 19:04:19 +01:00
open-amp lib: open-amp: optional copy of rsc_table to memory region 2025-03-24 12:17:53 +01:00
os lib/os/fdtable: Remove ifdef on NATIVE_POSIX 2025-03-12 02:27:36 +01:00
posix posix: remove deprecated kconfig options 2025-03-12 19:03:52 +01:00
runtime
smf lib: smf: Fix handled bug causing events to not propagate. 2025-01-23 19:24:08 +01:00
utils json: Fix calculation of object size 2025-04-08 11:44:51 +02:00
CMakeLists.txt lib: net_buf: move the network buffer implementation to lib 2024-09-07 11:19:05 -05:00
Kconfig lib: net_buf: move the network buffer implementation to lib 2024-09-07 11:19:05 -05:00