thumbnail: Check shm size before writing to it
The SHM is created by the application, which might've done a different size calculation. Verify that the data fits instead of writing past the end and crashing.
Reportedly avoids crashes, but the cause for the shm size mismatch still needs to be found and fixed.