summaryrefslogtreecommitdiff
path: root/myisam/myisampack.c
diff options
context:
space:
mode:
authorunknown <ingo@mysql.com>2005-04-28 16:09:53 +0200
committerunknown <ingo@mysql.com>2005-04-28 16:09:53 +0200
commit6aab4f49206b9bf2e673dc06710182a1b57a2e4d (patch)
tree5a30fe5e5413105f8ba6b5ff0402945abd14b0c7 /myisam/myisampack.c
parentd46255b1d9182d248d0372af3e012ac8ad68218d (diff)
parent0cb748039688225519502fd94844dcdcf7d01a71 (diff)
downloadmariadb-git-6aab4f49206b9bf2e673dc06710182a1b57a2e4d.tar.gz
Bug#8321 - myisampack bug in compression algorithm
Merge from 4.0.
Diffstat (limited to 'myisam/myisampack.c')
-rw-r--r--myisam/myisampack.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/myisam/myisampack.c b/myisam/myisampack.c
index 263a468d96d..88f38be3c54 100644
--- a/myisam/myisampack.c
+++ b/myisam/myisampack.c
@@ -31,6 +31,7 @@
#define __GNU_LIBRARY__ /* Skip warnings in getopt.h */
#endif
#include <my_getopt.h>
+#include <assert.h>
#if INT_MAX > 32767
#define BITS_SAVED 32
@@ -1991,7 +1992,9 @@ static void write_bits (register ulong value, register uint bits)
{
reg3 uint byte_buff;
bits= (uint) -file_buffer.bits;
- byte_buff=file_buffer.current_byte | (uint) (value >> bits);
+ DBUG_ASSERT(bits <= 8 * sizeof(value));
+ byte_buff= (file_buffer.current_byte |
+ ((bits != 8 * sizeof(value)) ? (uint) (value >> bits) : 0));
#if BITS_SAVED == 32
*file_buffer.pos++= (byte) (byte_buff >> 24) ;
*file_buffer.pos++= (byte) (byte_buff >> 16) ;
@@ -1999,7 +2002,9 @@ static void write_bits (register ulong value, register uint bits)
*file_buffer.pos++= (byte) (byte_buff >> 8) ;
*file_buffer.pos++= (byte) byte_buff;
- value&=(1 << bits)-1;
+ DBUG_ASSERT(bits <= 8 * sizeof(ulong));
+ if (bits != 8 * sizeof(value))
+ value&= (((ulong) 1) << bits) - 1;
#if BITS_SAVED == 16
if (bits >= sizeof(uint))
{