Skip to content

Commit dc4bd4c

Browse files
sboothCopilot
andauthored
Validate k in getRiceGolombCode (#903)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 242fe4b commit dc4bd4c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Sources/CSFBAudioEngine/Decoders/SFBShortenDecoder.mm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,12 @@ bool allocate(size_t size = 512) noexcept {
142142

143143
bool getRiceGolombCode(int32_t &i32, int k) noexcept {
144144
#if DEBUG
145-
assert(k < 32);
145+
assert(k >= 0 && k < 32);
146146
#endif /* DEBUG */
147+
if (k < 0 || k > 31) {
148+
return false;
149+
}
150+
147151
if (bitsAvailable_ == 0 && !refillBitBuffer()) {
148152
return false;
149153
}

0 commit comments

Comments
 (0)