Fix crash when input data isn't a multiple of the storage size