Allocate memory from heap to fix compile errors with gcc-4.8+.

Change-Id: I7be1c96b7d40226815446cd5d8dc32d82cfe55de