added check to avoid array out of boud access
Merge pull request #1025 from BytesGalore/add_out_of_bounds_check

sys:posix:pthread added check to avoid array out of bound access