check if array index ocsid is set before accessing it

please review @MorrisJobke @karlitschek @RealRancor