Index: src/main/random.c
===================================================================
--- src/main/random.c	(revision 44693)
+++ src/main/random.c	(working copy)
@@ -44,7 +44,7 @@
     for (i = 0; i < n; i++) {
 	ai = a[i % na];
 	x[i] = f(ai);
-	if (!R_FINITE(x[i])) naflag = 1;
+	if (!R_FINITE(x[i]) && R_FINITE(ai)) naflag = 1;
     }
     return(naflag);
 }
@@ -81,6 +81,7 @@
     if (na < 1) {
 	for (i = 0; i < n; i++)
 	    REAL(x)[i] = NA_REAL;
+        warning(_("NAs produced"));
     }
     else {
 	PROTECT(a = coerceVector(CADR(args), REALSXP));
@@ -116,14 +117,14 @@
 	ai = a[i % na];
 	bi = b[i % nb];
 	x[i] = f(ai, bi);
-	if (!R_FINITE(x[i])) naflag = 1;
+	if (!R_FINITE(x[i]) && R_FINITE(ai) && R_FINITE(bi)) naflag = 1;
     }
     return(naflag);
 }
 
 #define RAND2(num,name) \
 	case num: \
-		random2(name, REAL(a), na, REAL(b), nb, REAL(x), n); \
+		naflag = random2(name, REAL(a), na, REAL(b), nb, REAL(x), n); \
 		break
 
 /* "do_random2" - random sampling from 2 parameter families. */
@@ -155,6 +156,7 @@
     if (na < 1 || nb < 1) {
 	for (i = 0; i < n; i++)
 	    REAL(x)[i] = NA_REAL;
+        warning(_("NAs produced"));
     }
     else {
 	PROTECT(a = coerceVector(CADR(args), REALSXP));
@@ -200,14 +202,14 @@
 	bi = b[i % nb];
 	ci = c[i % nc];
 	x[i] = f(ai, bi, ci);
-	if (!R_FINITE(x[i])) naflag = TRUE;
+	if (!R_FINITE(x[i]) && R_FINITE(ai) && R_FINITE(bi) && R_FINITE(ci)) naflag = TRUE;
     }
     return(naflag);
 }
 
 #define RAND3(num,name) \
 	case num: \
-		random3(name, REAL(a), na, REAL(b), nb, REAL(c), nc, REAL(x), n); \
+		naflag = random3(name, REAL(a), na, REAL(b), nb, REAL(c), nc, REAL(x), n); \
 		break
 
 
@@ -244,6 +246,7 @@
     if (na < 1 || nb < 1 || nc < 1) {
 	for (i = 0; i < n; i++)
 	    REAL(x)[i] = NA_REAL;
+        warning(_("NAs produced"));
     }
     else {
 	PROTECT(a = coerceVector(a, REALSXP));
