Skip to content

Commit 48b70f0

Browse files
author
Sebastien Bourdeauducq
committedMay 27, 2012
software/libbase: fix memcpy handling of buffers with differing alignments
1 parent 4dbc938 commit 48b70f0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎software/libbase/libc.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ void *memcpy(void *to, const void *from, size_t n)
265265
from = cfrom;
266266
n--;
267267
}
268+
if((long)from & 1) {
269+
char *cto = to;
270+
const char *cfrom = from;
271+
for (; n; n--)
272+
*cto++ = *cfrom++;
273+
return xto;
274+
}
268275
if(n > 2 && (long)to & 2) {
269276
short *sto = to;
270277
const short *sfrom = from;
@@ -278,7 +285,7 @@ void *memcpy(void *to, const void *from, size_t n)
278285
long *lto = to;
279286
const long *lfrom = from;
280287
for(; temp; temp--)
281-
*lto++ = *lfrom++;
288+
*lto++ = *lfrom++;
282289
to = lto;
283290
from = lfrom;
284291
}

0 commit comments

Comments
 (0)
Please sign in to comment.