diff --git a/Core/Font/PGF.cpp b/Core/Font/PGF.cpp index ae3afa57b848..deec9d589eff 100644 --- a/Core/Font/PGF.cpp +++ b/Core/Font/PGF.cpp @@ -53,8 +53,10 @@ static int getBits(int numBits, const u8 *buf, size_t pos) { const u8 done = 32 - bitoff; const u8 remaining = numBits - done; - const u32 mask = (1 << remaining) - 1; - v |= (wordbuf[wordpos + 1] & mask) << done; + if (remaining > 0) { + const u32 mask = (1 << remaining) - 1; + v |= (wordbuf[wordpos + 1] & mask) << done; + } return v; } }