Return an empty surface if this happens, and log a warning.
trace: gdb.log
demo jpeg: test.jpg
This might not be the best way to handle this, but it seemed the simplest - let me know if you want it done differently, or just disregard the patch, as I mainly just wanted to point out the issue. I'm not sure whether any sort of user notification would be warranted here or not.