From 1ba117a8e9a31158b6844a0774e069ab18e5fb80 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 1 Dec 2022 03:39:06 +0300 Subject: [PATCH] engine: client: netgraph: fix few global-buffer-overflow errors --- engine/client/cl_netgraph.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engine/client/cl_netgraph.c b/engine/client/cl_netgraph.c index 7c9ee99a..51c5a4e5 100644 --- a/engine/client/cl_netgraph.c +++ b/engine/client/cl_netgraph.c @@ -281,7 +281,10 @@ static void NetGraph_DrawTimes( wrect_t rect, int x, int w ) for( j = start; j < h; j++ ) { - NetGraph_DrawRect( &fill, netcolors[NETGRAPH_NET_COLORS + j + extrap_point] ); + int color = NETGRAPH_NET_COLORS + j + extrap_point; + color = Q_min( color, ARRAYSIZE( netcolors ) - 1 ); + + NetGraph_DrawRect( &fill, netcolors[color] ); fill.top--; } } @@ -297,7 +300,10 @@ static void NetGraph_DrawTimes( wrect_t rect, int x, int w ) for( j = 0; j < h; j++ ) { - NetGraph_DrawRect( &fill, netcolors[NETGRAPH_NET_COLORS + j + oldh] ); + int color = NETGRAPH_NET_COLORS + j + oldh; + color = Q_min( color, ARRAYSIZE( netcolors ) - 1 ); + + NetGraph_DrawRect( &fill, netcolors[color] ); fill.top--; } }