From 8166e41e1fc9ea304b710049ece872a7de5c88cb Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 10 May 2021 17:47:47 +0200 Subject: [PATCH] translate: assert that nr_elements is in range MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This just ensures that we don't end up reading/writing outside of the space reserved in the key. This would have made it easier to to track down the issue in the previous commit faster. Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/translate/translate.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/auxiliary/translate/translate.h b/src/gallium/auxiliary/translate/translate.h index 0b50020..b70d90b 100644 --- a/src/gallium/auxiliary/translate/translate.h +++ b/src/gallium/auxiliary/translate/translate.h @@ -139,6 +139,7 @@ boolean translate_is_output_format_supported(enum pipe_format format); static inline int translate_keysize( const struct translate_key *key ) { + assert(key->nr_elements <= TRANSLATE_MAX_ATTRIBS); return 2 * sizeof(int) + key->nr_elements * sizeof(struct translate_element); } -- 2.7.4