OSDN Git Service

translate: Fix translate_key_compare().
authorMichal Krol <michal@vmware.com>
Tue, 29 Dec 2009 21:49:31 +0000 (22:49 +0100)
committerMichal Krol <michal@vmware.com>
Tue, 29 Dec 2009 21:49:31 +0000 (22:49 +0100)
Sizes of translate keys must also match.

src/gallium/auxiliary/translate/translate.h

index 34526eb..1afdf19 100644 (file)
@@ -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);
 }