uncompress: Avoid reading an extra byte
When reading the next code in a stream, avoid reading an extra byte if
we're going to throw it away. When there's no more bits to extract from
the stream, bits will be 0 and we'll mask the read byte with 0 anyway.
At worst, this will avoid reading one past the end of gbuf array (which
is not possible in well formed streams).
PR: 127912
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D47041
(cherry picked from commit 818c7b769a)
This commit is contained in:
parent
197de660d2
commit
03b4f23235
1 changed files with 2 additions and 1 deletions
|
|
@ -623,7 +623,8 @@ getcode(struct s_zstate *zs)
|
|||
}
|
||||
|
||||
/* High order bits. */
|
||||
gcode |= (*bp & rmask[bits]) << r_off;
|
||||
if (bits > 0)
|
||||
gcode |= (*bp & rmask[bits]) << r_off;
|
||||
roffset += n_bits;
|
||||
|
||||
return (gcode);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue