Add checks for pointers before using them
This probably doesn't solve the bug, but I've noticed that sometimes
when working with larger images, a tool cannot access the current
node, so that might be one reason for this crash to happen.
CCBUG:407228