Fix for malicious optimisation of memcpy in test suite, which causes failure with...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 10 Dec 2014 23:16:37 +0000 (23:16 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 10 Dec 2014 23:16:37 +0000 (23:16 +0000)
changelog
regress/hcommon.c
regress/hcommon.c.m4

index a3e7dbb..fedd31a 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,6 +1,8 @@
 adns (1.5.1~~) unstable; urgency=low
 
   * Portability fix for systems where socklen_t is bigger than int.
+  * Fix for malicious optimisation of memcpy in test suite, which
+    causes failure with gcc-4.1.9 -O3.  See Debian bug #772718.
 
  --
 
index ebbef94..e63a8cd 100644 (file)
@@ -281,7 +281,7 @@ void *Hrealloc(void *op, size_t nsz) {
   size_t osz;
   if (op) { oldnode= (void*)((char*)op - MALLOCHSZ); osz= oldnode->sz; } else { osz= 0; }
   np= Hmalloc(nsz);
-  memcpy(np,op, osz>nsz ? nsz : osz);
+  if (osz) memcpy(np,op, osz>nsz ? nsz : osz);
   Hfree(op);
   return np;
 }
index c5069ee..330da4d 100644 (file)
@@ -301,7 +301,7 @@ void *Hrealloc(void *op, size_t nsz) {
 
   if (op) { oldnode= (void*)((char*)op - MALLOCHSZ); osz= oldnode->sz; } else { osz= 0; }
   np= Hmalloc(nsz);
-  memcpy(np,op, osz>nsz ? nsz : osz);
+  if (osz) memcpy(np,op, osz>nsz ? nsz : osz);
   Hfree(op);
   return np;
 }