File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -548,7 +548,16 @@ public synchronized REXP eval(String s, boolean convert) {
548548 if (pr != 0 ) {
549549 long er = rniEval (pr , 0 );
550550 if (er != 0 ) {
551- REXP x = new REXP (this , er , convert );
551+ REXP x ;
552+ if (convert ) {
553+ rniProtect (er );
554+ try {
555+ x = new REXP (this , er , convert );
556+ } finally {
557+ rniUnprotect (1 );
558+ }
559+ } else
560+ x = new REXP (this , er , convert );
552561 if (DEBUG >0 ) System .out .println ("Rengine.eval(" +s +"): END (OK)" +Thread .currentThread ());
553562 return x ;
554563 }
Original file line number Diff line number Diff line change @@ -156,19 +156,24 @@ JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniEval
156156 /* invalid (NULL) expression (parse error, ... ) */
157157 if (!exp ) return 0 ;
158158
159+ PROTECT (exps );
159160 if (TYPEOF (exps ) == EXPRSXP ) {
160161 /* if the object is a list of exps, eval them one by one */
161162 l = LENGTH (exps );
162163 while (i < l ) {
163164 es = R_tryEval (VECTOR_ELT (exps ,i ), eval_env , & er );
164165
165166 /* an error occured, no need to continue */
166- if (er ) return 0 ;
167+ if (er ) {
168+ UNPROTECT (1 );
169+ return 0 ;
170+ }
167171 i ++ ;
168172 }
169173 } else
170174 es = R_tryEval (exps , eval_env , & er );
171-
175+ UNPROTECT (1 );
176+
172177 /* er is just a flag - on error return 0 */
173178 if (er ) return 0 ;
174179
You can’t perform that action at this time.
0 commit comments