It happens here:
When this happens, compositing is skipped. There are cases where this is a bug (e.g. composite destination-in where the destination is used to mask the source, if the destination is empty, the final image should be empty too, but due to this code, the source is untouched.
Possible solution is creating an empty image when the original image is null: