Skip to content

Commit b053385

Browse files
committed
R_UnwindProtect eval
1 parent 2ccc4d4 commit b053385

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/aio.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,17 @@ static void request_complete_signal(void *arg) {
252252

253253
}
254254

255+
static void release_object(void *data, Rboolean jump) {
256+
if (jump)
257+
R_ReleaseObject((SEXP) data);
258+
}
259+
255260
static void raio_invoke_cb(void *arg) {
256-
SEXP callExpr;
257-
PROTECT(callExpr = Rf_lcons((SEXP) arg, R_NilValue));
258-
(void) Rf_eval(callExpr, R_GlobalEnv);
261+
SEXP call, data = (SEXP) arg;
262+
PROTECT(call = Rf_lcons(data, R_NilValue));
263+
(void) R_UnwindProtect(eval_safe, call, release_object, data, NULL);
259264
UNPROTECT(1);
260-
R_ReleaseObject(arg);
265+
R_ReleaseObject(data);
261266
}
262267

263268
static void raio_complete_cb(void *arg) {

src/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ SEXP mk_error(const int xc) {
4242

4343
}
4444

45-
static SEXP eval_safe (void *call) {
45+
SEXP eval_safe (void *call) {
4646
return Rf_eval((SEXP) call, R_GlobalEnv);
4747
}
4848

src/nanonext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ typedef struct nano_buf_s {
192192

193193
SEXP mk_error(const int);
194194
SEXP mk_error_ncurl(const int);
195+
SEXP eval_safe(void *);
195196
nano_buf nano_char_buf(const SEXP);
196197
SEXP nano_decode(unsigned char *, const size_t, const int);
197198
void nano_encode(nano_buf *, const SEXP);

0 commit comments

Comments
 (0)