I'm implementing a red-black search tree as described Introduction To Algorithms 3rd Edition.
I have a problem where the tree doesn't get properly recolored after deleting a node with no children. On page 324 is described the RB-DELETE function. If a node is a leaf node, it's child pointers point to a special null node.
What I don't understand is, that when this function is run on a leaf node, it assigns the null node to x, then replaces the node with the subtree of null, thus altering the parent pointer of null. In the end, it runs the fixup method on null.
Shouldn't editing the null node be illegal? And what am I not understanding, why doesn't it work?
Before delete of 2:

After delete of 2:
