fix mem leak on error handling

Change-Id: I40d8e371c46184aa701fa676246201a9d8f6e27d
Merge "fix mem leak on error handling" into cm-10.1