[exim-cvs] Memory debug: do not try to save allocation bytes…

Inizio della pagina
Delete this message
Reply to this message
Autore: Exim Git Commits Mailing List
Data:  
To: exim-cvs
Oggetto: [exim-cvs] Memory debug: do not try to save allocation bytes used for debug as ACL can modify debugging status
Gitweb: https://git.exim.org/exim.git/commitdiff/1e30b0199daf7a7a882458251a3dc10d45d4c7d1
Commit:     1e30b0199daf7a7a882458251a3dc10d45d4c7d1
Parent:     87193ab87011f7c61fd9164e2a09913a55944340
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Sat Mar 27 23:49:50 2021 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Sun Mar 28 16:04:01 2021 +0100


    Memory debug: do not try to save allocation bytes used for debug as ACL can modify debugging status
---
 src/src/store.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)


diff --git a/src/src/store.c b/src/src/store.c
index 8faefd4..9de3f3f 100644
--- a/src/src/store.c
+++ b/src/src/store.c
@@ -201,7 +201,6 @@ for (int i = 0; i < NPOOLS; i++)
yield_length[i] = -1;
store_block_order[i] = 12; /* log2(allocation_size) ie. 4kB */
}
-store_block_order[POOL_MAIN] = 13;
}

/******************************************************************************/
@@ -814,10 +813,7 @@ internal_store_malloc(int size, const char *func, int line)
{
void * yield;

-#ifndef COMPILE_UTILITY
-DEBUG(D_memory) size += sizeof(int);    /* space to store the size */
-#endif
-
+size += sizeof(int);    /* space to store the size, used under debug */
 if (size < 16) size = 16;


 if (!(yield = malloc((size_t)size)))
@@ -825,8 +821,9 @@ if (!(yield = malloc((size_t)size)))
     "called from line %d in %s", size, line, func);


#ifndef COMPILE_UTILITY
-DEBUG(D_memory) { *(int *)yield = size; yield = US yield + sizeof(int); }
+DEBUG(D_any) *(int *)yield = size;
#endif
+yield = US yield + sizeof(int);

 if ((nonpool_malloc += size) > max_nonpool_malloc)
   max_nonpool_malloc = nonpool_malloc;
@@ -873,9 +870,9 @@ Returns:      nothing
 static void
 internal_store_free(void * block, const char * func, int linenumber)
 {
-uschar * p = block;
+uschar * p = US block - sizeof(int);
 #ifndef COMPILE_UTILITY
-DEBUG(D_memory) { p -= sizeof(int); nonpool_malloc -= *(int *)p; }
+DEBUG(D_any) nonpool_malloc -= *(int *)p;
 DEBUG(D_memory) debug_printf("----Free %6p %5d bytes\t%-20s %4d\n", block, *(int *)p, func, linenumber);
 #endif
 free(p);