Maybe worth checking if orig is not already larger or equal to 1048576 in case some other piece of code decides to increase the limit?