One line fix for nil reference bug

This is a one line fix for a bug causing crashes for me.
The present code is adding an object to an array, without
first checking if the object reference is not nil.