Index: /branches/eam_branches/ipp-20130509/Ohana/src/delstar/include/delstar.h
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/delstar/include/delstar.h	(revision 35726)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/delstar/include/delstar.h	(revision 35727)
@@ -155,5 +155,5 @@
 
 void initImageIndex (ImageSubset *image, off_t Nimage_init);
-int *getImageIndex ();
+int *getImageIndex (int *maxIndex);
 int FindIDexp (off_t *ID, off_t *Seq, e_time time, short photcode);
 int FindIDstk (off_t *ID, off_t *Seq, short *photcode, off_t extID);
Index: /branches/eam_branches/ipp-20130509/Ohana/src/delstar/src/ImageOpsFixLAP.c
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/delstar/src/ImageOpsFixLAP.c	(revision 35726)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/delstar/src/ImageOpsFixLAP.c	(revision 35727)
@@ -14,4 +14,5 @@
 unsigned int *imageSeq_stk = NULL;
 
+int maxID = 0;
 int *imageIndex = NULL;
 
@@ -44,6 +45,4 @@
   memset (Nimage_invalid, 0, sizeof(int)*Nimage);
 
-  int maxID = 0;
-
   // save the image data in the local static arrays
   for (i = 0; i < Nimage; i++) {
@@ -85,5 +84,6 @@
 }
 
-int *getImageIndex () {
+int *getImageIndex (int *maxIDout) {
+  *maxIDout = maxID;
   return imageIndex;
 }
Index: /branches/eam_branches/ipp-20130509/Ohana/src/delstar/src/delete_fix_LAP.c
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/delstar/src/delete_fix_LAP.c	(revision 35726)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/delstar/src/delete_fix_LAP.c	(revision 35727)
@@ -64,5 +64,6 @@
 
     // skip if nothing was deleted
-    if (UPDATE && (NaverageStart == catalog.Naverage) && (NmeasureStart == catalog.Nmeasure)) {
+    int noChange = (NaverageStart == catalog.Naverage) && (NmeasureStart == catalog.Nmeasure);
+    if (UPDATE && !noChange) {
       dvo_catalog_save_complete (&catalog, VERBOSE2);
     }
@@ -518,5 +519,6 @@
   }
 
-  int *imageIndex = getImageIndex();
+  int maxID = 0;
+  int *imageIndex = getImageIndex(&maxID);
 
   // check the image IDs for the remaining measures
@@ -532,4 +534,8 @@
 	resetID = TRUE;
 	goto resetID_exp;
+      }
+      if (imageID > maxID) {
+	fprintf (stderr, "invalid image ID "OFF_T_FMT" for catalog %s\n", imageID, catalog[0].filename);
+	exit (2);
       }
       off_t imageN = imageIndex[imageID];
@@ -587,4 +593,8 @@
 	goto resetID_stk;
       }
+      if (imageID > maxID) {
+	fprintf (stderr, "invalid image ID "OFF_T_FMT" for catalog %s\n", imageID, catalog[0].filename);
+	exit (2);
+      }
 
       off_t imageN = imageIndex[imageID];
