Memory leak: if any of the above returns NULL, you lose the pointer. Do the check first, then assign to member variables.