ECMS-5948: ArrayIndexOutOfBoundsException when saving an ECMS script

Fix description:
  - verify the array size before access the first element