fix potential memory leak

use delete before return

Change-Id: I5449ad90bb6910f057bd825b722c9803a7343c34