move include to top of the service.cpp file.
fix missing null pointer check after malloc.