[UBSan] Don't overflow when calculating memory range that should be dumped