Fix memory leak in cfgex tool

Change-Id: Ic8c410a805fa06777c1a85de646df2dcd5b6506a