[rkward-cvs] SF.net SVN: rkward-code:[4657] trunk/rkward/rkward/rbackend/ rkstructuregetter.cpp

tfry at users.sf.net tfry at users.sf.net
Tue Apr 2 16:21:15 UTC 2013


Revision: 4657
          http://sourceforge.net/p/rkward/code/4657
Author:   tfry
Date:     2013-04-02 16:21:14 +0000 (Tue, 02 Apr 2013)
Log Message:
-----------
For good measure, use protects, everywhere. (Addition to r4654)

Revision Links:
--------------
    http://sourceforge.net/p/rkward/code/4654

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rkstructuregetter.cpp

Modified: trunk/rkward/rkward/rbackend/rkstructuregetter.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkstructuregetter.cpp	2013-04-02 14:53:02 UTC (rev 4656)
+++ trunk/rkward/rkward/rbackend/rkstructuregetter.cpp	2013-04-02 16:21:14 UTC (rev 4657)
@@ -197,10 +197,15 @@
 
 	if ((TYPEOF (value) == LANGSXP) || (TYPEOF (value) == SYMSXP)) {	// if it's a call, we should NEVER send it through eval
 		// stripped down and adjusted from R_data_class
-		classes = RKRSupport::SEXPToStringList(Rf_getAttrib (value, R_ClassSymbol));
+		PROTECT (classes_s = Rf_getAttrib (value, R_ClassSymbol));
+		classes = RKRSupport::SEXPToStringList(classes_s);
+		UNPROTECT (1);
 		if (classes.isEmpty ()) {
 			if (TYPEOF (value) == LANGSXP) {
-				QString cl = RKRSupport::SEXPToString (PRINTNAME (value));
+				SEXP cl_s = PRINTNAME (value);
+				PROTECT (cl_s);
+				QString cl = RKRSupport::SEXPToString (cl_s);
+				UNPROTECT (1);
 				if ((cl != "if") && (cl != "while") && (cl != "for") && (cl != "=") && (cl != "<-") && (cl != "(") && (cl != "{")) cl = "call";
 				classes = QStringList (cl);
 			} else {
@@ -210,8 +215,9 @@
 
 		REPROTECT (value = Rf_coerceVector (value, EXPRSXP), value_index);	// make sure the object is safe for everything to come
 	} else {
-		classes_s = RKRSupport::callSimpleFun (class_fun, value, baseenv);
+		PROTECT (classes_s = RKRSupport::callSimpleFun (class_fun, value, baseenv));
 		classes = RKRSupport::SEXPToStringList (classes_s);
+		UNPROTECT (1);
 	}
 
 	// store classes





More information about the rkward-tracker mailing list