From: Hector Martin Date: Tue, 18 Jan 2011 02:33:38 +0000 (+0100) Subject: Fix out of bounds access for empty frames X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=3e7989891b1e8d9c70177175003e85a10988bc24;p=openlase-old.git Fix out of bounds access for empty frames This was causing broken float values (NaN) which kill the output processor. --- diff --git a/libol/libol.c b/libol/libol.c index b755b14..eb2385c 100644 --- a/libol/libol.c +++ b/libol/libol.c @@ -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;