Revert "Related: deb#766788 alloc on heap instead of stack"

This reverts commit acdf54c4142b7a51b99eacacee470ac31d6ff0ae.

Change-Id: I1c49a5baac3a3421d23926f4479e674ef46fbf34
coverity#1213364 Untrusted loop bound

Change-Id: Ifa9912386d34c1bed40dd02d17e4e5402fc82592