Bug 14773 - GC-protection in R_set_class() (coerce.c)
GC-protection in R_set_class() (coerce.c)
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Low-level
R-devel (trunk)
All All
: P5 minor
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-03 12:50 UTC by Andrew Runnalls
Modified: 2012-01-05 13:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Runnalls 2012-01-03 12:50:09 UTC
In coerce.c (at rev. 56316) in the function R_set_class() at around line 2473:

    if(TYPEOF(value) != STRSXP) {
	/* Beware: assumes value is protected, which it is
	   in the only use below */
	PROTECT(value = coerceVector(duplicate(value), STRSXP));
	nProtect++;
    }

duplicate(value) is not protected and can potentially be blown away by allocations within coerceVector().

(Discovered during CXXR development.)

Andrew
Comment 1 Brian Ripley 2012-01-05 13:50:13 UTC
Thanks, fixed in 2.14.1 patched.