Fix literals length calculation
diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c
index a0b6b42..c19b243 100644
--- a/lib/compress/zstd_compress.c
+++ b/lib/compress/zstd_compress.c
@@ -4587,6 +4587,7 @@
                 break;
             } else {
                 /* Spanned range ends in the match section */
+                litLength = seqRange->startPosInSequence > litLength ? 0 : litLength - seqRange->startPosInSequence;
                 matchLength = seqLength - litLength;
             }