Internally the image and texture resources where kept in a vector where the elements were referenced. When using more than 16 images this vector is reallocated and previous references become invalid. This is a quick fix and should be changed with something more stable. Pull Request: https://projects.blender.org/blender/blender/pulls/123656