]> granicus.if.org Git - sysstat/commitdiff
Revert "Fix #148: ARM: sadc crashes because of unaligned memory accesses"
authorSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 10 Jul 2017 14:59:09 +0000 (16:59 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 10 Jul 2017 15:11:19 +0000 (17:11 +0200)
This reverts commit 569378eb1a3be23cdb45ac5d39e354683a7748f8.
Proposed fix for #148 "sadc crashes because of unaligned memory access"
doesn't work properly:
Copying old pointer contents to new pointer destination uses the size of
the memory pointed to by the newly allocated pointer... which is not the
size of the memory the old pointer was pointing to. The result is you
may get a segmentation fault in some cases.
So for now, revert the corresponding patch, awaiting a better solution.

common.h

index bb54c43db7d4b09f1e0cef697a587fc85c7e315a..bcda7a1c86805c27db8e9358ee101ac81be2bb15 100644 (file)
--- a/common.h
+++ b/common.h
@@ -11,7 +11,6 @@
 
 #include <time.h>
 #include <sched.h>     /* For __CPU_SETSIZE */
-#include <stdlib.h>
 #include <limits.h>
 
 #ifdef HAVE_SYS_SYSMACROS_H
 #define SREALLOC(S, TYPE, SIZE)        do {                                                             \
                                        TYPE *_p_ = S;                                           \
                                        if (SIZE) {                                              \
-                                               void *_ptr = NULL;                               \
-                                               int error = posix_memalign(&_ptr, 16, (SIZE));   \
-                                               if (error || (_ptr == NULL)) {                   \
+                                               if ((S = (TYPE *) realloc(S, (SIZE))) == NULL) { \
                                                        perror("realloc");                       \
                                                        exit(4);                                 \
                                                }                                                \
-                                               S = (TYPE *)_ptr;                                \
                                                /* If the ptr was null, then it's a malloc() */  \
                                                if (!_p_) {                                      \
                                                        memset(S, 0, (SIZE));                    \
                                                }                                                \
-                                               else {                                           \
-                                                       memcpy(S, _p_, (SIZE));                  \
-                                               }                                                \
                                        }                                                        \
                                        if (!S) {                                                \
                                                /* Should never happen */                        \