Fixed potential memory leak.

Change-Id: I84474f4d0fbc4074053f82faa8445bdccce8ede6