From d52302e9cb04a26c03219da3be74ed68d37cf5d3 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 25 Aug 2008 01:40:31 +0000 Subject: *** empty log message *** --- lzf_c.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'lzf_c.c') diff --git a/lzf_c.c b/lzf_c.c index c1847f3..848aa22 100644 --- a/lzf_c.c +++ b/lzf_c.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2007 Marc Alexander Lehmann + * Copyright (c) 2000-2008 Marc Alexander Lehmann * * 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 */ } -- cgit v1.2.3