]> Some of my projects - openlase-old.git/commitdiff
Fix out of bounds access for empty frames
authorHector Martin <hector@marcansoft.com>
Tue, 18 Jan 2011 02:33:38 +0000 (03:33 +0100)
committerHector Martin <hector@marcansoft.com>
Tue, 18 Jan 2011 02:33:38 +0000 (03:33 +0100)
This was causing broken float values (NaN) which kill the output
processor.

libol/libol.c

index b755b140b8353812bdf0ec56a138e26913cab044..eb2385cce8daeeb01a8920bff70161c29057aa4c 100644 (file)
@@ -835,8 +835,13 @@ float olRenderFrame(int max_fps)
                last_info.resampled_points = count;
        }
 
-       float last_x = frames[cwbuf].points[count-1].x;
-       float last_y = frames[cwbuf].points[count-1].y;
+       float last_x, last_y;
+       if (count) {
+               last_x = frames[cwbuf].points[count-1].x;
+               last_y = frames[cwbuf].points[count-1].y;
+       } else {
+               last_x = last_y = 0;
+       }
        while(count < min_points) {
                frames[cwbuf].points[count].x = last_x;
                frames[cwbuf].points[count].y = last_y;