fbBlt - memcpy on overlapping ranges

Michal Srb msrb at suse.com
Thu May 24 08:20:16 PDT 2012


Hi,

In fb/fbblt.c in fbBlt function, memcpy is used to blit inside lines:

if (!upsidedown)
     for (i = 0; i < height; i++)
         MEMCPY_WRAPPED(dst + i * dstStride, src + i * srcStride, width);
else
     for (i = height - 1; i >= 0; i--)
         MEMCPY_WRAPPED(dst + i * dstStride, src + i * srcStride, width);


Where MEMCPY_WRAPPED is normaly expanded to standard memcpy function.

In case of blitting in horizontal direction of less than width overlapping 
will occur. According to memcpy documentation, result is undefined in such 
case. Shouldn't memmove be used instead?

(This does happen, found using clang's AddressSanitizer - steps I used: run X 
without any client in vmware, then kate and then kwin.)

Michal


More information about the xorg-devel mailing list