aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common/vli_encoder.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/liblzma/common/vli_encoder.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/src/liblzma/common/vli_encoder.c b/src/liblzma/common/vli_encoder.c
index c48d6474..53022f16 100644
--- a/src/liblzma/common/vli_encoder.c
+++ b/src/liblzma/common/vli_encoder.c
@@ -31,10 +31,12 @@ lzma_vli_encode(lzma_vli vli, size_t *restrict vli_pos,
vli_pos = &vli_pos_internal;
// Validate the arguments.
- if (*vli_pos >= LZMA_VLI_BYTES_MAX || *out_pos >= out_size
- || vli > LZMA_VLI_VALUE_MAX)
+ if (*vli_pos >= LZMA_VLI_BYTES_MAX || vli > LZMA_VLI_VALUE_MAX)
return LZMA_PROG_ERROR;
+ if (*out_pos >= out_size)
+ return LZMA_BUF_ERROR;
+
// Write the non-last bytes in a loop.
while ((vli >> (*vli_pos * 7)) >= 0x80) {
out[*out_pos] = (uint8_t)(vli >> (*vli_pos * 7)) | 0x80;
@@ -55,20 +57,3 @@ lzma_vli_encode(lzma_vli vli, size_t *restrict vli_pos,
return vli_pos == &vli_pos_internal ? LZMA_OK : LZMA_STREAM_END;
}
-
-
-extern LZMA_API uint32_t
-lzma_vli_size(lzma_vli vli)
-{
- if (vli > LZMA_VLI_VALUE_MAX)
- return 0;
-
- uint32_t i = 0;
- do {
- vli >>= 7;
- ++i;
- } while (vli != 0);
-
- assert(i <= LZMA_VLI_BYTES_MAX);
- return i;
-}