Fix possible SIGSEGV on large thumbnail generation with external thumbnailer.