]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
liblzma: Refactor a loop in lzma_filters_copy() coverity
authorLasse Collin <lasse.collin@tukaani.org>
Sun, 2 Nov 2025 10:57:00 +0000 (12:57 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Sun, 2 Nov 2025 10:57:00 +0000 (12:57 +0200)
Arguably it's nicer if i doesn't wrap around when the loop terminates.

Fixes: Coverity CID 464589
Fixes: 6d118a0b9def ("Add lzma_filters_copy().")
src/liblzma/common/filter_common.c

index d15d9cc94f9962f49a3cfd3d40dd362e767f9ed8..6c06c78ddc152bb30a62c30a76115a4922a06ec5 100644 (file)
@@ -213,8 +213,8 @@ lzma_filters_copy(const lzma_filter *src, lzma_filter *real_dest,
 
 error:
        // Free the options which we have already allocated.
-       while (i-- > 0)
-               lzma_free(dest[i].options, allocator);
+       while (i > 0)
+               lzma_free(dest[--i].options, allocator);
 
        return ret;
 }