Skip to content

Commit 50393d1

Browse files
committed
IBF: Remove unnecessary and potentially UB pointer cast
[Bug #21569]
1 parent 354d47a commit 50393d1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compile.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14002,7 +14002,11 @@ struct ibf_object_symbol {
1400214002

1400314003
#define IBF_ALIGNED_OFFSET(align, offset) /* offset > 0 */ \
1400414004
((((offset) - 1) / (align) + 1) * (align))
14005-
#define IBF_OBJBODY(type, offset) (const type *)\
14005+
/* No cast, since it's UB to create an unaligned pointer.
14006+
* Leave as void* for use with memcpy in those cases.
14007+
* We align the offset, but the buffer pointer is only VALUE aligned,
14008+
* so the returned pointer may be unaligned for `type` .*/
14009+
#define IBF_OBJBODY(type, offset) \
1400614010
ibf_load_check_offset(load, IBF_ALIGNED_OFFSET(RUBY_ALIGNOF(type), offset))
1400714011

1400814012
static const void *

0 commit comments

Comments
 (0)