Fix a division by zero

The bug only manifest at particular store size and memory configurations.