Problem: stack->offset value is used as an array index. Solution: Instead of comparing the stack->offset value to the size in bytes of the array, compare the actual length of the array.