Coverity: Negative RETURNS: CID 106
authorNelson Ferreira <nelson.ferreira@ieee.org>
Fri, 20 Jan 2012 03:42:32 +0000 (22:42 -0500)
committerNelson Ferreira <nelson.ferreira@ieee.org>
Fri, 20 Jan 2012 03:42:32 +0000 (22:42 -0500)
* src/indent.c (vpix_motion): Try to handle more safely the
crashing fatally scenario...

Signed-off-by: Nelson Ferreira <nelson.ferreira@ieee.org>
src/indent.c

index 290386e..d0c303b 100644 (file)
@@ -571,10 +571,15 @@ static int vpix_motion(line_start_cache_dynarr * cache, int start, int end)
        assert(start >= 0);
        assert(end < Dynarr_length(cache));
 
+       if (start<0 || end<0 || end>start) {
+               /* Least bad thing in case of in fatal_failure, where
+                  assert will not terminate this function... */
+               return 0;
+       } 
+
        vpix = 0;
        for (i = start; i <= end; i++)
                vpix += Dynarr_atp(cache, i)->height;
-
        return vpix;
 }