]> wimlib.net Git - wimlib/blobdiff - src/xpress-decompress.c
{lzx,xpress}_decode_match(): Fix undefined pointer evalution
[wimlib] / src / xpress-decompress.c
index e9aec1361bee7ed61664053995e63c37d09f462f..cf08a836276f9478e20874738c55b290f6a6cb26 100644 (file)
@@ -143,22 +143,22 @@ xpress_decode_match(unsigned huffsym, unsigned window_pos,
         * currently in use, then copy the source of the match to the current
         * position. */
 
-       match_dest = window + window_pos;
-       match_src = match_dest - match_offset;
-
        if (window_pos + match_len > window_len) {
                DEBUG("XPRESS decompression error: match of length %u "
                      "bytes overflows window", match_len);
                return -1;
        }
 
-       if (match_src < window) {
+       if (match_offset > window_pos) {
                DEBUG("XPRESS decompression error: match of length %u bytes "
                      "references data before window (match_offset = %u, "
                      "window_pos = %u)", match_len, match_offset, window_pos);
                return -1;
        }
 
+       match_dest = window + window_pos;
+       match_src = match_dest - match_offset;
+
        for (i = 0; i < match_len; i++)
                match_dest[i] = match_src[i];