post_proc: fix post and pre process KW issues

KW issue fix includes:
- handle memory allocation failure
- array index boundary check

Change-Id: I083952ba58d348a5b650601a83e6f492b0d686bb