Remove unneeded null check.
Fix the potential of a dereference of null pointer.
Remove unneeded code.
Remove unneeded length check to avoid the potential of a dereference of
null pointer.
Fix the potential of memory leaks in our test suit.