From 13a3797683e06fc55c5e19415fe70d0caef53f08 Mon Sep 17 00:00:00 2001 From: "josh.macdonald" Date: Tue, 15 Apr 2008 04:01:06 +0000 Subject: Fixes for issue 70. The test inputs tickled a case where the non-blocking API would not make progress, searching for match on the page boundary and repeatedly asking the application to get another source block. This is only a non-blocking issue, glad it's fixed. I'll add encode_decode_test to my test suite before another release. --- xdelta3/xdelta3.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'xdelta3/xdelta3.c') diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 17985ae..3a0c6e8 100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c @@ -3813,7 +3813,16 @@ xd3_encode_input (xd3_stream *stream) return ret; } - stream->input_position += stream->match_fwd; + /* The search has to make forward progress here + * or else it can get stuck in a match-backward + * (getsrcblk) then match-forward (getsrcblk), + * find insufficient match length, then repeat + * exactly the same search. */ + if (stream->match_fwd != 0) { + stream->input_position += stream->match_fwd; + } else { + stream->input_position += 1; + } } case MATCH_SEARCHING: @@ -4741,7 +4750,7 @@ xd3_smatch (xd3_stream *stream, again: - IF_DEBUG1 (DP(RINT "smatch at base=%u inp=%u cksum=%u\n", base, + IF_DEBUG2 (DP(RINT "smatch at base=%u inp=%u cksum=%u\n", base, stream->input_position, scksum)); /* For small matches, we can always go to the end-of-input because -- cgit v1.2.3