X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Flzms_compress.c;h=8db49668d296bf8d0340235ae78a4bc78aa372cf;hb=ba9577d39906b70c591e4d898d5f05ca909d59e1;hp=caa93130c75ca44f656a1d8464621985d6eb3bd1;hpb=dadccd777e56b473128d87e485fcf8565b8cb93b;p=wimlib diff --git a/src/lzms_compress.c b/src/lzms_compress.c index caa93130..8db49668 100644 --- a/src/lzms_compress.c +++ b/src/lzms_compress.c @@ -307,7 +307,8 @@ struct lzms_compressor { u32 next_delta_hashes[NUM_POWERS_TO_CONSIDER]; /* The per-byte graph nodes for near-optimal parsing */ - struct lzms_optimum_node optimum_nodes[NUM_OPTIM_NODES + MAX_FAST_LENGTH]; + struct lzms_optimum_node optimum_nodes[NUM_OPTIM_NODES + MAX_FAST_LENGTH + + 1 + MAX_FAST_LENGTH]; /* Table: length => current cost for small match lengths */ u32 fast_length_cost_tab[MAX_FAST_LENGTH + 1]; @@ -946,7 +947,7 @@ lzms_encode_item_list(struct lzms_compressor *c, } /****************************************************************************** - * Cost evalution * + * Cost evaluation * ******************************************************************************/ /* @@ -1764,6 +1765,11 @@ begin: span); const u32 raw_offset = offset >> power; + + if (unlikely(raw_offset > DELTA_SOURCE_RAW_OFFSET_MASK - + (LZMS_NUM_DELTA_REPS - 1))) + continue; + const u32 pair = (power << DELTA_SOURCE_POWER_SHIFT) | raw_offset; const u32 source = DELTA_SOURCE_TAG |