mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-io: reorder struct mrb_io to keep fd at offset 0
move fd, fd2, pid fields before the bitfield flags while keeping the pointer field last. this preserves the 24-byte struct size (same as 3.4.0) while restoring fd to offset 0 (same as 3.3.0). some external gems (e.g. mruby-polarssl) pass struct mrb_io pointers directly to libraries like mbedtls that expect an int fd at offset 0. the 3.4.0 reorder moved bitfield flags to offset 0, causing these gems to read garbage instead of the file descriptor. fixes #6713 Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,9 @@ struct mrb_io_buf {
|
||||
};
|
||||
|
||||
struct mrb_io {
|
||||
int fd; /* file descriptor, or -1 */
|
||||
int fd2; /* file descriptor to write if it's different from fd, or -1 */
|
||||
int pid; /* child's pid (for pipes) */
|
||||
unsigned int readable:1,
|
||||
writable:1,
|
||||
eof:1,
|
||||
@@ -39,9 +42,6 @@ struct mrb_io {
|
||||
is_socket:1,
|
||||
close_fd:1,
|
||||
close_fd2:1;
|
||||
int fd; /* file descriptor, or -1 */
|
||||
int fd2; /* file descriptor to write if it's different from fd, or -1 */
|
||||
int pid; /* child's pid (for pipes) */
|
||||
struct mrb_io_buf *buf;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user