From 7124fa16efe0f8ffb402bcd182f276032bed378d Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 29 Dec 2009 22:49:31 +0100 Subject: translate: Fix translate_key_compare(). Sizes of translate keys must also match. --- src/gallium/auxiliary/translate/translate.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/gallium/auxiliary/translate') diff --git a/src/gallium/auxiliary/translate/translate.h b/src/gallium/auxiliary/translate/translate.h index 34526eb061..1afdf194b3 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); } -- cgit v1.2.3