dvd-sector-copy.c: Calculate the clear-area size consistently.
[dvdrip] / dvd-sector-copy.c
index 73e068a..40ee26d 100644 (file)
@@ -743,8 +743,8 @@ static ssize_t find_good_sector(secaddr *pos_inout, secaddr end,
     step = (step_factor - 1)*(bad_hi - bad_lo);
     if (step < step_min) step = step_min;
     if (step_max && step > step_max) step = step_max;
-    if (step > end - bad_hi) step = end - bad_hi;
-    pos = bad_hi + step - 1;
+    step += bad_hi - bad_lo;
+    if (step > end - bad_lo) step = end - bad_lo;
     want = run_length_wanted(pos, step, end);
     n = recovery_read(&r, pos, want);
 #ifdef DEBUG