When you apply this, please put the remaining array-overflow checksbefore the overflow occurs, not after. See patches I just appliedin the back branches.
regards, tom lane