From: Michal Krol Date: Tue, 29 Dec 2009 21:49:31 +0000 (+0100) Subject: translate: Fix translate_key_compare(). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7124fa16efe0f8ffb402bcd182f276032bed378d;p=mesa.git translate: Fix translate_key_compare(). Sizes of translate keys must also match. --- diff --git a/src/gallium/auxiliary/translate/translate.h b/src/gallium/auxiliary/translate/translate.h index 34526eb0617..1afdf194b31 100644 --- a/src/gallium/auxiliary/translate/translate.h +++ b/src/gallium/auxiliary/translate/translate.h @@ -103,8 +103,13 @@ static INLINE int translate_keysize( const struct translate_key *key ) static INLINE int translate_key_compare( const struct translate_key *a, const struct translate_key *b ) { - int keysize = translate_keysize(a); - return memcmp(a, b, keysize); + int keysize_a = translate_keysize(a); + int keysize_b = translate_keysize(b); + + if (keysize_a != keysize_b) { + return keysize_a - keysize_b; + } + return memcmp(a, b, keysize_a); }