Index: trunk/magic/remove/src/diffedpixels.c
===================================================================
--- trunk/magic/remove/src/diffedpixels.c	(revision 27348)
+++ trunk/magic/remove/src/diffedpixels.c	(revision 27360)
@@ -1,4 +1,6 @@
 #include "streaksremove.h"
 #include "pmAstrometryWCS.h"
+
+#define DEBUG_PRINT 1
 
 static void addTouchedPixels(streakFiles *sf, psString fileName);
@@ -125,5 +127,4 @@
 
     // put the corners in the desired order (see comments below)
-
     nameCorners(pt);
     psString type;
@@ -246,5 +247,5 @@
           0--------------
                  A                  right boundary: line 1_2 y < pt2.y
-                   1                                line 2_3  y >= pt.y
+                   1                                line 2_3 y >= pt2.y
 **************************
 
@@ -311,6 +312,19 @@
         tr = pt[0];
     }
-    if (tl.y >= tr.y) {
-        // Type 1 (or 3 which is equivalent)
+    int type = 0;
+    int type3 = 0;
+    if (round(tl.x) == round(bl.x)) {
+        type3 = 1;
+        if (tl.y <= tr.y) {
+            type = 1;
+        } else {
+            type = 2;
+        }
+    } else if (tl.y >= tr.y) {
+        type = 1;
+    } else {
+        type = 2;
+    }
+    if (type == 1) {
         pt[0] = bl;
         pt[1] = br;
@@ -361,6 +375,9 @@
         streaksExit("", PS_EXIT_PROG_ERROR);
     }
+
     // pt2 is below or at the same y as pt3
-    if (pt[2].y > pt[3].y) {
+    // This can happen with some strange shapes. Accept this with type3
+    // since our edge conditions are still satisfied
+    if (!type3 && (pt[2].y > pt[3].y)) {
         fprintf(stderr, "ERROR calculating diff overlap\n");
         fprintf(stderr, "pt[2].y (%f) > pt[3].y (%f)\n", pt[2].y, pt[3].y);
