Skip to content
Snippets Groups Projects
Commit 6394f0fd authored by Yaowu Xu's avatar Yaowu Xu
Browse files

Reorder operation to avoid UBsan warning

The original order of operations lead to all variables upgraded to
unsigned int during computation, and enc->cnt being negative then
would cause UBsan warning.

Change-Id: I658b6f4c903472b82e178033eac2463045c42233
parent a517d9f4
No related branches found
No related tags found
No related merge requests found
......@@ -398,7 +398,7 @@ unsigned char *od_ec_enc_done(od_ec_enc *enc, uint32_t *nbytes) {
int od_ec_enc_tell(const od_ec_enc *enc) {
/*The 10 here counteracts the offset of -9 baked into cnt, and adds 1 extra
bit, which we reserve for terminating the stream.*/
return (enc->offs + enc->end_offs) * 8 + enc->cnt + enc->nend_bits + 10;
return (enc->cnt + 10 + enc->nend_bits) + (enc->offs + enc->end_offs) * 8;
}
/*Returns the number of bits "used" by the encoded symbols so far.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment