termux-packages/packages/wrk/crash-fix.patch

26 lines
727 B
Diff

diff -ur wrk-4.1.0-orig/src/zmalloc.c wrk-4.1.0/src/zmalloc.c
--- wrk-4.1.0-orig/src/zmalloc.c 2020-05-07 01:47:50.562052028 +0000
+++ wrk-4.1.0/src/zmalloc.c 2020-05-07 01:48:12.281671231 +0000
@@ -45,13 +45,19 @@
#include "zmalloc.h"
#include "atomicvar.h"
+#ifdef _LP64
+#define ALIGMENT (16)
+#else
+#define ALIGMENT (8)
+#endif
+#define ROUND_UP(n,r) (((n + r - 1) / r ) * r)
#ifdef HAVE_MALLOC_SIZE
#define PREFIX_SIZE (0)
#else
#if defined(__sun) || defined(__sparc) || defined(__sparc__)
-#define PREFIX_SIZE (sizeof(long long))
+#define PREFIX_SIZE (ROUND_UP(sizeof(long long), ALIGMENT))
#else
-#define PREFIX_SIZE (sizeof(size_t))
+#define PREFIX_SIZE (ROUND_UP(sizeof(size_t), ALIGMENT))
#endif
#endif