summaryrefslogtreecommitdiff
path: root/tools/lz/mpcomp.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lz/mpcomp.c')
-rw-r--r--tools/lz/mpcomp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lz/mpcomp.c b/tools/lz/mpcomp.c
index 5961be8eb..c8829852c 100644
--- a/tools/lz/mpcomp.c
+++ b/tools/lz/mpcomp.c
@@ -101,7 +101,7 @@ struct command pick_copy_for_pass (const unsigned char * data, const unsigned ch
current = buffer + refpos - (length - 3);
else
current = reference + refpos;
- if (memcmp(data + position, current, 4)) continue;
+ if (memcmp(data + position, current, ((position + 4) > length) ? length - position : 4)) continue;
for (count = 4; (count < (length - position)) && (count < (length - refpos)); count ++) if (data[position + count] != current[count]) break;
if (count > (length - refpos)) count = length - refpos;
if (count > (length - position)) count = length - position;