[Encode] Fix kw errors for memory leak

Release previously allocated memory;

Change-Id: I1641d029963921468e92f5cc41a96d944b2535e3
3 files changed