Fix integer overflows in internal memalign and malloc functions [BZ #22343]