From 0075e909add775a9223751b29e340b5ef10fec80 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Mon, 10 Jul 2017 16:59:09 +0200 Subject: [PATCH] Revert "Fix #148: ARM: sadc crashes because of unaligned memory accesses" 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 | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/common.h b/common.h index bb54c43..bcda7a1 100644 --- a/common.h +++ b/common.h @@ -11,7 +11,6 @@ #include #include /* For __CPU_SETSIZE */ -#include #include #ifdef HAVE_SYS_SYSMACROS_H @@ -125,20 +124,14 @@ #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 */ \ -- 2.40.0