diff options
Diffstat (limited to 'lzf_c.c')
-rw-r--r-- | lzf_c.c | 43 |
1 files changed, 23 insertions, 20 deletions
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2007 Marc Alexander Lehmann <schmorp@schmorp.de> + * Copyright (c) 2000-2008 Marc Alexander Lehmann <schmorp@schmorp.de> * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: @@ -208,7 +208,7 @@ lzf_compress (const void *const in_data, unsigned int in_len, break; } - len -= 2; + len -= 2; /* len is now #octets - 1 */ ip++; if (len < 7) @@ -223,31 +223,34 @@ lzf_compress (const void *const in_data, unsigned int in_len, *op++ = off; + if (expect_true (ip + len < in_end - 2)) + { #if ULTRA_FAST || VERY_FAST - ip += len; -#if VERY_FAST && !ULTRA_FAST - --ip; -#endif - hval = FRST (ip); + ip += len; +# if VERY_FAST && !ULTRA_FAST + --ip; +# endif + hval = FRST (ip); - hval = NEXT (hval, ip); - htab[IDX (hval)] = ip; - ip++; + hval = NEXT (hval, ip); + htab[IDX (hval)] = ip; + ip++; -#if VERY_FAST && !ULTRA_FAST - hval = NEXT (hval, ip); - htab[IDX (hval)] = ip; - ip++; -#endif -#else - do - { +# if VERY_FAST && !ULTRA_FAST hval = NEXT (hval, ip); htab[IDX (hval)] = ip; ip++; - } - while (len--); +# endif +#else + do + { + hval = NEXT (hval, ip); + htab[IDX (hval)] = ip; + ip++; + } + while (len--); #endif + } lit = 0; op++; /* start run */ } |