summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonal.k.fellows@manchester.ac.uk <dkf>2007-01-22 09:56:32 (GMT)
committerdonal.k.fellows@manchester.ac.uk <dkf>2007-01-22 09:56:32 (GMT)
commit06a8aab748fbe0ef46ef1fb4edb1bba68af19367 (patch)
treec435470ac8667e76f680ae55177b80fdb6db96b1
parentfe9a886489d71442bb3ad55f09354d61e2b0c6e8 (diff)
downloadtcl-06a8aab748fbe0ef46ef1fb4edb1bba68af19367.zip
tcl-06a8aab748fbe0ef46ef1fb4edb1bba68af19367.tar.gz
tcl-06a8aab748fbe0ef46ef1fb4edb1bba68af19367.tar.bz2
Fix [Bug 1631017]
-rw-r--r--ChangeLog5
-rw-r--r--compat/memcmp.c9
2 files changed, 10 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 2ec53a9..a1eeba0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-22 Donal K. Fellows <donal.k.fellows@man.ac.uk>
+
+ * compat/memcmp.c (memcmp): Reworked so that arithmetic is never
+ performed upon void pointers, since that is illegal. [Bug 1631017]
+
2006-01-19 Daniel Steffen <das@users.sourceforge.net>
* macosx/tclMacOSXNotify.c: accommodate changes to prototypes of
diff --git a/compat/memcmp.c b/compat/memcmp.c
index 09a5724..dd4cacc 100644
--- a/compat/memcmp.c
+++ b/compat/memcmp.c
@@ -48,11 +48,12 @@ memcmp(s1, s2, n)
CONST VOID *s2; /* Second string. */
size_t n; /* Length to compare. */
{
- unsigned char u1, u2;
+ VOID unsigned char *ptr1 = (VOID unsigned char *) s1;
+ VOID unsigned char *ptr2 = (VOID unsigned char *) s2;
+
+ for ( ; n-- ; ptr1++, ptr2++) {
+ unsigned char u1 = *s1, u2 = *s2;
- for ( ; n-- ; s1++, s2++) {
- u1 = * (unsigned char *) s1;
- u2 = * (unsigned char *) s2;
if ( u1 != u2) {
return (u1-u2);
}