fix memory corruption when building the variant

Change-Id: I9dd89dee44bb6c981b2f0de82e013722c34cb720