Skip to content

arith_dynamic: Encode fails with X_CAT #144

@zaeleus

Description

@zaeleus

Encoding with arith_dynamic and the X_CAT (0x20) flag fails. E.g.,

$ echo -n "htscodecs" | tests/arith_dynamic -r -o32
$ echo $?
1

The encoder has a special case for X_CAT but does not return early, which, in the example, later causes the order 0 encoder to fail. The encoder works as expected when returning early:

diff --git a/htscodecs/arith_dynamic.c b/htscodecs/arith_dynamic.c
index 9f891ee..0817910 100644
--- a/htscodecs/arith_dynamic.c
+++ b/htscodecs/arith_dynamic.c
@@ -759,6 +759,7 @@ unsigned char *arith_compress_to(unsigned char *in,  unsigned int in_size,
         }
         memcpy(out+c_meta_len, in, in_size);
         *out_size = in_size+c_meta_len;
+        return out;
     }
 
     if (order & X_STRIPE) {

This may have gone unnoticed since the tests omit X_CAT.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions