Skip to content

Commit c5164ca

Browse files
committed
fix use after seen in cqe handlers
fixes #123
1 parent e6f2d04 commit c5164ca

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/uring/uring_stubs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,9 @@ value ocaml_uring_wait_cqe_timeout(value v_timeout, value v_uring)
972972
if (!cqe)
973973
CAMLreturn(Val_cqe_none);
974974
id = (long)io_uring_cqe_get_data(cqe);
975+
int cqe_res = cqe->res;
975976
io_uring_cqe_seen(ring, cqe);
976-
CAMLreturn(Val_cqe_some(Val_int(id), Val_int(cqe->res)));
977+
CAMLreturn(Val_cqe_some(Val_int(id), Val_int(cqe_res)));
977978
}
978979
}
979980

@@ -996,8 +997,9 @@ value ocaml_uring_wait_cqe(value v_uring)
996997
}
997998
} else {
998999
id = (long)io_uring_cqe_get_data(cqe);
1000+
int cqe_res = cqe->res;
9991001
io_uring_cqe_seen(ring, cqe);
1000-
CAMLreturn(Val_cqe_some(Val_int(id), Val_int(cqe->res)));
1002+
CAMLreturn(Val_cqe_some(Val_int(id), Val_int(cqe_res)));
10011003
}
10021004
}
10031005

@@ -1018,8 +1020,9 @@ value ocaml_uring_peek_cqe(value v_uring)
10181020
}
10191021
} else {
10201022
id = (long)io_uring_cqe_get_data(cqe);
1023+
int cqe_res = cqe->res;
10211024
io_uring_cqe_seen(ring, cqe);
1022-
CAMLreturn(Val_cqe_some(Val_int(id), Val_int(cqe->res)));
1025+
CAMLreturn(Val_cqe_some(Val_int(id), Val_int(cqe_res)));
10231026
}
10241027
}
10251028

0 commit comments

Comments
 (0)