The linked blog post is very much worth a read too ( https://medium.com/realmodelabs/kindledrip-from-your-kindles... ) and includes such gems as -
"The reference code prevents this issue with an assert that checks num_channels is less then MAX_CHANNELS. But maybe the Kindle developers missed it? I popped libjpegXR.so in Ghidra to look at how they chose to implement it."