c++
BOOL freerdp_image_copy(...) {
    // ...
    const UINT32 dstByte = FreeRDPGetBytesPerPixel(DstFormat);
    const UINT32 srcByte = FreeRDPGetBytesPerPixel(SrcFormat);

    if ((nHeight > INT32_MAX) || (nWidth > INT32_MAX) || 
        nXDst > UINT32_MAX / dstByte ||
        nYDst > UINT32_MAX / nDstStep ||
        nXDst * dstByte > UINT32_MAX - nYDst * nDstStep) // Combined check here
       return FALSE;
    // ... rest of the function
}
