Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Fix problem surfaced by R-2.5.0. Namely, check for a R_NilValue return

  from R_Parsevector() before trying to feed the result to VECTOR_ELT().
  This happens, for example, when a parse error is caught. Reported by
  Steve Singer.
  • Loading branch information...
commit eb1f22e512b18f69fe131c92a008c19abf786419 1 parent 7e682c0
jconway authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 plr.c
View
12 plr.c
@@ -1238,15 +1238,21 @@ plr_parse_func_body(const char *body)
{
SEXP rbody;
SEXP fun;
+ SEXP tmp;
int status;
PROTECT(rbody = NEW_CHARACTER(1));
SET_STRING_ELT(rbody, 0, COPY_TO_USER_STRING(body));
- PROTECT(fun = VECTOR_ELT(R_PARSEVECTOR(rbody, -1, &status), 0));
+ tmp = PROTECT(R_PARSEVECTOR(rbody, -1, &status));
+ if (tmp != R_NilValue)
+ PROTECT(fun = VECTOR_ELT(tmp, 0));
+ else
+ PROTECT(fun = R_NilValue);
+
if (status != PARSE_OK)
{
- UNPROTECT(2);
+ UNPROTECT(3);
if (last_R_error_msg)
ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
@@ -1260,7 +1266,7 @@ plr_parse_func_body(const char *body)
"in \"%s\".", body)));
}
- UNPROTECT(2);
+ UNPROTECT(3);
return(fun);
}
Please sign in to comment.
Something went wrong with that request. Please try again.