Index: /branches/eam_branches/ipp-20110906/Ohana/src/opihi/cmd.astro/ringflux.c
===================================================================
--- /branches/eam_branches/ipp-20110906/Ohana/src/opihi/cmd.astro/ringflux.c	(revision 32609)
+++ /branches/eam_branches/ipp-20110906/Ohana/src/opihi/cmd.astro/ringflux.c	(revision 32610)
@@ -1,5 +1,17 @@
 # include "astro.h"
 
-# define FLUX(BUF,X,Y) { out[Nvec] = BUF[(int)(X) + ((int)(Y))*Nx]; Nvec++; }
+# define FLUX(BUF,X,Y) {						\
+	char valid = TRUE;						\
+	valid &= (X >= 0);						\
+	valid &= (Y >= 0);						\
+	valid &= (X < Nx);						\
+	valid &= (Y < Ny);						\
+	if (valid) {							\
+	    out[Nvec] = BUF[(int)(X) + ((int)(Y))*Nx];			\
+	    Nvec++;							\
+	    if (Nvec >= vec[0].Nelements) abort();			\
+	}								\
+    }
+
 # define C1 0
 
@@ -64,4 +76,5 @@
 	  // counting error here
 	ResetVector (vec, OPIHI_FLT, vec[0].Nelements + 64);
+	out = vec[0].elements.Flt;
       }
 
