mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-10-20 11:29:35 +00:00
Better code to make human-friendly tokens for pointers in log-malloc.
It turns out that subtracting NULL from a pointer to turn it into an integer is not a good idea, because subtracting a NULL pointer is undefined behaviour in C. The correct way to do this is simply to cast the pointer to uintptr_t. The only fly in this ointment is that the C standard does not mandate support for uintptr_t. In practice, I doubt anyone is running dnsmasq on the long-dead architectures where this might be a problem. Thanks to Matthias Andree for the heads-up.
This commit is contained in:
1 file changed
+1
-1
+1
-1
@@ -947,7 +947,7 @@ int kernel_version(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#define hash_ptr(x) (((unsigned int)(((char *)(x)) - ((char *)NULL))) & 0xffffff)
|
||||
#define hash_ptr(x) (((uintptr_t)(x)) & 0xffffff)
|
||||
|
||||
void *whine_malloc_real(const char *func, unsigned int line, size_t size)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user