[Pomp-commits] r395 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Oct 23 17:58:50 CEST 2010


Author: kingaa
Date: 2010-10-23 17:58:49 +0200 (Sat, 23 Oct 2010)
New Revision: 395

Modified:
   pkg/src/probe.c
Log:

- prevent protection stack overflow with nsim large


Modified: pkg/src/probe.c
===================================================================
--- pkg/src/probe.c	2010-10-23 14:50:42 UTC (rev 394)
+++ pkg/src/probe.c	2010-10-23 15:58:49 UTC (rev 395)
@@ -15,7 +15,6 @@
   for (i = 0; i < nprobe; i++) {
     SET_ELEMENT(vals,i,eval(lang2(VECTOR_ELT(probes,i),data),CLOENV(VECTOR_ELT(probes,i))));
     if (!IS_NUMERIC(VECTOR_ELT(vals,i))) {
-      UNPROTECT(nprotect);
       error("probe %ld returns a non-numeric result",i);
     }
   }
@@ -97,9 +96,8 @@
       }
 
       // evaluate the probe on the simulated data
-      PROTECT(val = eval(lang2(VECTOR_ELT(probes,p),x),CLOENV(VECTOR_ELT(probes,p)))); nprotect++;
+      PROTECT(val = eval(lang2(VECTOR_ELT(probes,p),x),CLOENV(VECTOR_ELT(probes,p))));
       if (!IS_NUMERIC(val)) {
-	UNPROTECT(nprotect);
 	error("probe %ld returns a non-numeric result",p);
       }
 
@@ -107,7 +105,6 @@
       if (s == 0)
 	len0 = len;
       else if (len != len0) {
-	UNPROTECT(nprotect);
 	error("variable-sized results returned by probe %ld",p);
       }
       if (k+len > nvals)
@@ -116,6 +113,7 @@
       xp = REAL(retval); yp = REAL(val);
       for (i = 0; i < len; i++) xp[s+nsims*(i+k)] = yp[i];
 
+      UNPROTECT(1);
     }
     
   }



More information about the pomp-commits mailing list