I had used a static analyzer cppcheck to improve the code. This analyzer suggested NULL check for this code.