From ec2524eb971039a617794bf32e89751a2339c647 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 16 Mar 2016 21:48:21 -0700 Subject: [PATCH] GUAC-236: Do not exceed available buffers/layers/streams. --- src/guacenc/display-buffers.c | 4 ++-- src/guacenc/display-image-streams.c | 6 +++--- src/guacenc/display-layers.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/guacenc/display-buffers.c b/src/guacenc/display-buffers.c index 5bd68d35..8d230dd2 100644 --- a/src/guacenc/display-buffers.c +++ b/src/guacenc/display-buffers.c @@ -37,7 +37,7 @@ guacenc_buffer* guacenc_display_get_buffer(guacenc_display* display, int internal_index = -index - 1; /* Do not lookup / allocate if index is invalid */ - if (internal_index < 0 || internal_index > GUACENC_DISPLAY_MAX_BUFFERS) { + if (internal_index < 0 || internal_index >= GUACENC_DISPLAY_MAX_BUFFERS) { guacenc_log(GUAC_LOG_WARNING, "Buffer index out of bounds: %i", index); return NULL; } @@ -72,7 +72,7 @@ int guacenc_display_free_buffer(guacenc_display* display, int internal_index = -index - 1; /* Do not lookup / free if index is invalid */ - if (internal_index < 0 || internal_index > GUACENC_DISPLAY_MAX_BUFFERS) { + if (internal_index < 0 || internal_index >= GUACENC_DISPLAY_MAX_BUFFERS) { guacenc_log(GUAC_LOG_WARNING, "Buffer index out of bounds: %i", index); return 1; } diff --git a/src/guacenc/display-image-streams.c b/src/guacenc/display-image-streams.c index 46e4b867..e992512e 100644 --- a/src/guacenc/display-image-streams.c +++ b/src/guacenc/display-image-streams.c @@ -33,7 +33,7 @@ int guacenc_display_create_image_stream(guacenc_display* display, int index, int mask, int layer_index, const char* mimetype, int x, int y) { /* Do not lookup / allocate if index is invalid */ - if (index < 0 || index > GUACENC_DISPLAY_MAX_STREAMS) { + if (index < 0 || index >= GUACENC_DISPLAY_MAX_STREAMS) { guacenc_log(GUAC_LOG_WARNING, "Stream index out of bounds: %i", index); return 1; } @@ -54,7 +54,7 @@ guacenc_image_stream* guacenc_display_get_image_stream( guacenc_display* display, int index) { /* Do not lookup / allocate if index is invalid */ - if (index < 0 || index > GUACENC_DISPLAY_MAX_STREAMS) { + if (index < 0 || index >= GUACENC_DISPLAY_MAX_STREAMS) { guacenc_log(GUAC_LOG_WARNING, "Stream index out of bounds: %i", index); return NULL; } @@ -67,7 +67,7 @@ guacenc_image_stream* guacenc_display_get_image_stream( int guacenc_display_free_image_stream(guacenc_display* display, int index) { /* Do not lookup / allocate if index is invalid */ - if (index < 0 || index > GUACENC_DISPLAY_MAX_STREAMS) { + if (index < 0 || index >= GUACENC_DISPLAY_MAX_STREAMS) { guacenc_log(GUAC_LOG_WARNING, "Stream index out of bounds: %i", index); return 1; } diff --git a/src/guacenc/display-layers.c b/src/guacenc/display-layers.c index e0406f8b..51b9058b 100644 --- a/src/guacenc/display-layers.c +++ b/src/guacenc/display-layers.c @@ -33,7 +33,7 @@ guacenc_layer* guacenc_display_get_layer(guacenc_display* display, int index) { /* Do not lookup / allocate if index is invalid */ - if (index < 0 || index > GUACENC_DISPLAY_MAX_LAYERS) { + if (index < 0 || index >= GUACENC_DISPLAY_MAX_LAYERS) { guacenc_log(GUAC_LOG_WARNING, "Layer index out of bounds: %i", index); return NULL; } @@ -85,7 +85,7 @@ int guacenc_display_free_layer(guacenc_display* display, int index) { /* Do not lookup / free if index is invalid */ - if (index < 0 || index > GUACENC_DISPLAY_MAX_LAYERS) { + if (index < 0 || index >= GUACENC_DISPLAY_MAX_LAYERS) { guacenc_log(GUAC_LOG_WARNING, "Layer index out of bounds: %i", index); return 1; }