Remove memory leaks in launcher/dshell.c

This pull request refactor launcher/dshell.c.
We remove unnecessary code and remove memory leaks.