]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
afh: Make sure we never return a negative chunk number.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 20 Dec 2016 20:18:27 +0000 (21:18 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 28 Dec 2016 14:17:26 +0000 (15:17 +0100)
With the old code this could happen if chunk zero is empty.

afh_common.c

index f36c32e20ec6332a24720d9bf106ab9b39d756ba..dfbf75132f4e4372eb0b4c95bff8ef25793dc545 100644 (file)
@@ -295,8 +295,8 @@ int32_t afh_get_start_chunk(int32_t approx_chunk_num,
 
        for (k = PARA_MAX(0, approx_chunk_num); k >= 0; k--)
                if (get_chunk_len(k, afhi) > 0)
-                       break;
-       return k;
+                       return k;
+       return 0;
 }
 
 /**