X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=module%2Fzfs%2Flzjb.c;h=43d0df055d8e1eb013c0af3682aa2424af043da7;hb=389cf730cedd42dd1ef653e9358635c114e458d5;hp=ab3de51b7259a7ff230f3b2fae2c27c4c083c0b3;hpb=572e285762521df27fe5b026f409ba1a21abb7ac;p=zfs.git diff --git a/module/zfs/lzjb.c b/module/zfs/lzjb.c index ab3de51..43d0df0 100644 --- a/module/zfs/lzjb.c +++ b/module/zfs/lzjb.c @@ -36,7 +36,7 @@ * source length if compression would overflow the destination buffer. */ -#include +#include #define MATCH_BITS 6 #define MATCH_MIN 3 @@ -50,16 +50,19 @@ lzjb_compress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) { uchar_t *src = s_start; uchar_t *dst = d_start; - uchar_t *cpy, *copymap; + uchar_t *cpy, *copymap = NULL; int copymask = 1 << (NBBY - 1); int mlen, offset, hash; uint16_t *hp; - uint16_t lempel[LEMPEL_SIZE] = { 0 }; + uint16_t *lempel; + lempel = kmem_zalloc(LEMPEL_SIZE * sizeof (uint16_t), KM_PUSHPAGE); while (src < (uchar_t *)s_start + s_len) { if ((copymask <<= 1) == (1 << NBBY)) { - if (dst >= (uchar_t *)d_start + d_len - 1 - 2 * NBBY) + if (dst >= (uchar_t *)d_start + d_len - 1 - 2 * NBBY) { + kmem_free(lempel, LEMPEL_SIZE*sizeof(uint16_t)); return (s_len); + } copymask = 1; copymap = dst; *dst++ = 0; @@ -89,6 +92,8 @@ lzjb_compress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) *dst++ = *src++; } } + + kmem_free(lempel, LEMPEL_SIZE * sizeof (uint16_t)); return (dst - (uchar_t *)d_start); } @@ -99,7 +104,7 @@ lzjb_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) uchar_t *src = s_start; uchar_t *dst = d_start; uchar_t *d_end = (uchar_t *)d_start + d_len; - uchar_t *cpy, copymap; + uchar_t *cpy, copymap = 0; int copymask = 1 << (NBBY - 1); while (dst < d_end) {