[rkward-cvs] [rkward] rkward/rbackend: Safeguard against cases where a function expecting to return a logical does not.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Nov 24 09:43:21 UTC 2014


Git commit b78cdd7791aea93921f1dd40f94be15a081a556c by Thomas Friedrichsmeier.
Committed on 24/11/2014 at 09:42.
Pushed by tfry into branch 'master'.

Safeguard against cases where a function expecting to return a logical does not.

M  +5    -1    rkward/rbackend/rkrsupport.cpp

http://commits.kde.org/rkward/b78cdd7791aea93921f1dd40f94be15a081a556c

diff --git a/rkward/rbackend/rkrsupport.cpp b/rkward/rbackend/rkrsupport.cpp
index 097227c..0ee8413 100644
--- a/rkward/rbackend/rkrsupport.cpp
+++ b/rkward/rbackend/rkrsupport.cpp
@@ -69,7 +69,11 @@ SEXP RKRSupport::callSimpleFun2 (SEXP fun, SEXP arg1, SEXP arg2, SEXP env) {
 
 bool RKRSupport::callSimpleBool (SEXP fun, SEXP arg, SEXP env) {
 	SEXP res = callSimpleFun (fun, arg, env);
-	RK_ASSERT (TYPEOF (res) == LGLSXP);
+	if ((Rf_length (res) < 1) || (TYPEOF (res) != LGLSXP)) {
+		RK_ASSERT (TYPEOF (res) == LGLSXP);
+		RK_ASSERT (Rf_length (res) >= 1);
+		return false;
+	}
 	return ((bool) LOGICAL (res)[0]);
 }
 




More information about the rkward-tracker mailing list