I would guess that the OSID function is not returning any information, thus your variable ($os) is not an array, but is empty.

Validate the code by checking the VarType of $os...

Code:

If VarType($os) & 8192
; VarType is an array...
EndIf