Skip to content

Commit

Permalink
readRDS() and unserialize() now signal an errorr instead of returning…
Browse files Browse the repository at this point in the history
… a PROMSXP.

git-svn-id: https://svn.r-project.org/R/trunk@86235 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
luke committed Mar 31, 2024
1 parent 799e1b6 commit c06f7f2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/serialize.c
Expand Up @@ -2650,6 +2650,13 @@ do_serializeToConn(SEXP call, SEXP op, SEXP args, SEXP env)
return R_NilValue;
}

static SEXP checkNotPromise(SEXP val)
{
if (TYPEOF(val) == PROMSXP)
error(_("cannot return a promise (PROMSXP) object"));
return val;
}

/* unserializeFromConn(conn, hook) used from readRDS().
It became public in R 2.13.0, and that version added support for
connections internally */
Expand Down Expand Up @@ -2699,7 +2706,7 @@ do_unserializeFromConn(SEXP call, SEXP op, SEXP args, SEXP env)
con->close(con);
UNPROTECT(1);
}
return ans;
return checkNotPromise(ans);
}

/*
Expand Down Expand Up @@ -3330,8 +3337,8 @@ attribute_hidden SEXP
do_serialize(SEXP call, SEXP op, SEXP args, SEXP env)
{
checkArity(op, args);
if (PRIMVAL(op) == 2) return R_unserialize(CAR(args), CADR(args));

if (PRIMVAL(op) == 2) //return R_unserialize(CAR(args), CADR(args));
return checkNotPromise(R_unserialize(CAR(args), CADR(args)));
SEXP object, icon, type, ver, fun;
object = CAR(args); args = CDR(args);
icon = CAR(args); args = CDR(args);
Expand Down

0 comments on commit c06f7f2

Please sign in to comment.