[lib] Avoid use of VLAs

-> Eliminated possible stack overflows