mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
The error was that if `m_bytesPerRow` was not divisible by the number of bytes per column then ImHex would crash but wouldn't crash if it was. When `m_bytesPerRow` is not equal to the resultant bytes per row obtained by the product of column count and bytes per column, then the later bytes per row were be allocated but the former bytes per row were being written causing heap corruption and crashes. Instead of resetting `m_bytePerRow` when it can't be used, a new variable (`bytesPerRow`) is created with the correct value and used in the rest of the function. This way if the user goes back to choose a data size that divides the old `m_bytesPerRow` then the number would still be available and not overwritten. Test indicate that this approach works and previous crashes are eliminated while producing the desired output.