… | |
… | |
112 | const u8 *in_end = ip + in_len; |
112 | const u8 *in_end = ip + in_len; |
113 | u8 *out_end = op + out_len; |
113 | u8 *out_end = op + out_len; |
114 | const u8 *ref; |
114 | const u8 *ref; |
115 | |
115 | |
116 | unsigned int hval; |
116 | unsigned int hval; |
|
|
117 | #if WIN32 |
|
|
118 | unsigned _int64 off; /* workaround for microsoft bug (they claim to support POSIX) */ |
|
|
119 | #else |
117 | unsigned long off; |
120 | unsigned long off; |
|
|
121 | #endif |
118 | int lit; |
122 | int lit; |
119 | |
123 | |
120 | if (!in_len || !out_len) |
124 | if (!in_len || !out_len) |
121 | return 0; |
125 | return 0; |
122 | |
126 | |
… | |
… | |
157 | /* match found at *ref++ */ |
161 | /* match found at *ref++ */ |
158 | unsigned int len = 2; |
162 | unsigned int len = 2; |
159 | unsigned int maxlen = in_end - ip - len; |
163 | unsigned int maxlen = in_end - ip - len; |
160 | maxlen = maxlen > MAX_REF ? MAX_REF : maxlen; |
164 | maxlen = maxlen > MAX_REF ? MAX_REF : maxlen; |
161 | |
165 | |
162 | if (maxlen > 8) maxlen = 8;//D |
|
|
163 | |
|
|
164 | op [- lit - 1] = lit - 1; /* stop run */ |
166 | op [- lit - 1] = lit - 1; /* stop run */ |
165 | op -= !lit; /* undo run if length is zero */ |
167 | op -= !lit; /* undo run if length is zero */ |
166 | |
168 | |
167 | if (expect_false (op + 3 + 1 >= out_end)) |
169 | if (expect_false (op + 3 + 1 >= out_end)) |
168 | return 0; |
170 | return 0; |
… | |
… | |
256 | lit = 0; op++; /* start run */ |
258 | lit = 0; op++; /* start run */ |
257 | } |
259 | } |
258 | } |
260 | } |
259 | } |
261 | } |
260 | |
262 | |
261 | if (op + 2 > out_end) /* at most 2 bytes can be missing here */ |
263 | if (op + 3 > out_end) /* at most 3 bytes can be missing here */ |
262 | return 0; |
264 | return 0; |
263 | |
265 | |
264 | while (ip < in_end) |
266 | while (ip < in_end) |
265 | { |
267 | { |
266 | lit++; *op++ = *ip++; |
268 | lit++; *op++ = *ip++; |