I added the code assert(f->valid_bits >= n); instead of removing if (f->valid_bits < 0) return 0; to improve code with checking and debugging instead.
@@ -1601,6 +1601,8 @@ static uint32 get_bits(vorb *f, int n)
}
+ assert(f->valid_bits >= n);
+
z = f->acc & ((1 << n)-1);
f->acc >>= n;
f->valid_bits -= n;