fixed potential null dereference analyzer warnings

fixed XCode5 analyzer warnings.