# HG changeset patch # User Matt Johnston # Date 1519920126 -28800 # Node ID d4efb7801fcd9848dc6bb214c087f22a50d9e64f # Parent 67cb1983500b80a2350208cc5b95297b6c8d024c Attempt to fix m_free for libtomcrypt/libtommath diff -r 67cb1983500b -r d4efb7801fcd dbmalloc.h --- a/dbmalloc.h Thu Mar 01 23:47:46 2018 +0800 +++ b/dbmalloc.h Fri Mar 02 00:02:06 2018 +0800 @@ -1,7 +1,9 @@ #ifndef DBMALLOC_H_ #define DBMALLOC_H_ -#include "includes.h" +#include "stdint.h" +#include "stdlib.h" +#include "options.h" void * m_malloc(size_t size); void * m_calloc(size_t nmemb, size_t size); @@ -10,16 +12,16 @@ #if DROPBEAR_TRACKING_MALLOC void m_free_direct(void* ptr); -#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0) void m_malloc_set_epoch(unsigned int epoch); void m_malloc_free_epoch(unsigned int epoch, int dofree); #else /* plain wrapper */ - -#define m_free(X) do {free(X); (X) = NULL;} while (0) +#define m_free_direct free #endif +#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0) + #endif /* DBMALLOC_H_ */ diff -r 67cb1983500b -r d4efb7801fcd libtomcrypt/src/headers/tomcrypt_custom.h --- a/libtomcrypt/src/headers/tomcrypt_custom.h Thu Mar 01 23:47:46 2018 +0800 +++ b/libtomcrypt/src/headers/tomcrypt_custom.h Fri Mar 02 00:02:06 2018 +0800 @@ -12,12 +12,7 @@ #include "tomcrypt_dropbear.h" -void * m_malloc(size_t size); -/* m_calloc is limited in size, enough for libtomcrypt */ -void * m_calloc(size_t nmemb, size_t size); -void * m_realloc(void* ptr, size_t size); -void m_free_direct(void* ptr); - +#include "dbmalloc.h" #define XMALLOC m_malloc #define XFREE m_free_direct #define XREALLOC m_realloc diff -r 67cb1983500b -r d4efb7801fcd libtommath/tommath_class.h --- a/libtommath/tommath_class.h Thu Mar 01 23:47:46 2018 +0800 +++ b/libtommath/tommath_class.h Fri Mar 02 00:02:06 2018 +0800 @@ -1062,12 +1062,7 @@ #undef BN_MP_TOOM_MUL_C #undef BN_MP_TOOM_SQR_C -void * m_malloc(size_t size); -/* m_calloc is limited in size, enough for libtomcrypt */ -void * m_calloc(size_t nmemb, size_t size); -void * m_realloc(void* ptr, size_t size); -void m_free_direct(void* ptr); - +#include "dbmalloc.h" #define XMALLOC m_malloc #define XFREE m_free_direct #define XREALLOC m_realloc