Repository navigation
vclog: fix max realloc compiler error - #88
Conversation
Fixes
./vclog/vclog.c:211:34: error: argument 2 value '4294967288' exceeds maximum object size 2147483647 [-Werror=alloc-size-larger-than=]
211 | payload_buffer = realloc(payload_buffer, payload_buffer_size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./vclog/vclog.c:17:
../../toolchain/armv7ve-libreelec-linux-gnueabihf/sysroot/usr/include/stdlib.h:683:14: note: in a call to allocation function 'realloc' declared here
683 | extern void *realloc (void *__ptr, size_t __size)
| ^~~~~~~
|
Does this follow-up patch (which should be in heitbaum:patch-2 now) also work? It looks more correct to me. |
I didn’t like my version of 88 either (which is why I separated it from 87) but the size_t doesn’t work either. It matches 4GB too. |
If log_copy_wrap copies nothing, msg.size stays 0 and payload_len wraps to 0xfffffff8. The payload_len > log_size check can't exclude that at compile time, so 32-bit ARM gcc 14 at -O3 fails with: error: argument 2 value '4294967288' exceeds maximum object size 2147483647 [-Werror=alloc-size-larger-than=] Treat msg.size < sizeof(msg_hdr_t) as corruption, which also bounds payload_len to 16 bits. Revert the size_t change, which did not help on 32-bit targets. Signed-off-by: Dom Cobley <[email protected]>
|
I've pushed 5c5e2fd, which replaces both earlier attempts. Cause: if First version ( Second version ( This version: treats - if (payload_len > log_size)
+ if (msg.size < sizeof(msg_hdr_t) || payload_len > log_size)Testing: the error only shows with 32-bit ARM gcc 14/15 at
This PR, alone and merged with current master, also builds clean at |
|
@pelwell okay with this version? It will want a "squash and merge". |
./vclog/vclog.c:211:34: error: argument 2 value '4294967288' exceeds maximum object size 2147483647 [-Werror=alloc-size-larger-than=]
211 | payload_buffer = realloc(payload_buffer, payload_buffer_size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./vclog/vclog.c:17:
../../toolchain/armv7ve-libreelec-linux-gnueabihf/sysroot/usr/include/stdlib.h:683:14: note: in a call to allocation function 'realloc' declared here
683 | extern void *realloc (void *__ptr, size_t __size)
| ^~~~~~~