Skip to content

Commit 70780cf

Browse files
committed
Run read_console() within safely!
1 parent b668a16 commit 70780cf

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

crates/ark/src/interface.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ use harp::lock::R_RUNTIME_LOCK;
5353
use harp::lock::R_RUNTIME_LOCK_COUNT;
5454
use harp::object::RObject;
5555
use harp::r_lock;
56+
use harp::r_safely;
5657
use harp::r_symbol;
5758
use harp::routines::r_register_routines;
5859
use harp::session::r_poke_option_show_error_messages;
@@ -1064,7 +1065,7 @@ extern "C" fn r_read_console(
10641065
hist: c_int,
10651066
) -> i32 {
10661067
let main = unsafe { R_MAIN.as_mut().unwrap() };
1067-
let (out, interrupt) = main.read_console(prompt, buf, buflen, hist);
1068+
let (out, interrupt) = r_safely!(main.read_console(prompt, buf, buflen, hist));
10681069

10691070
// NOTE: Keep this function a "Plain Old Frame" without any
10701071
// destructors. We're longjumping from here in case of interrupt.

crates/harp/src/exec.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ where
430430
F: 'env,
431431
T: 'env,
432432
{
433+
// NOTE: Keep this function a Plain Old Frame without Drop destructors
434+
433435
let polled_events = unsafe { R_PolledEvents };
434436
let interrupts_suspended = unsafe { R_interrupts_suspended };
435437
unsafe {

crates/harp/src/session.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ static mut OPTIONS_FN: Option<SEXP> = None;
3232
pub fn r_n_frame() -> crate::error::Result<i32> {
3333
SESSION_INIT.call_once(init_interface);
3434

35-
r_safely! {
35+
unsafe {
3636
let ffi = r_try_eval_silent(NFRAME_CALL.unwrap_unchecked(), R_BaseEnv)?;
3737
let n_frame = IntegerVector::new(ffi)?;
3838
Ok(n_frame.get_unchecked_elt(0))
3939
}
4040
}
4141

4242
pub fn r_sys_frame(n: c_int) -> crate::error::Result<SEXP> {
43-
let mut protect = unsafe { RProtect::new() };
44-
r_safely! {
43+
unsafe {
44+
let mut protect = RProtect::new();
4545
let n = protect.add(Rf_ScalarInteger(n));
4646
let call = protect.add(r_lang!(r_symbol!("sys.frame"), n));
4747
Ok(r_try_eval_silent(call, R_BaseEnv)?)

0 commit comments

Comments
 (0)