diff --git a/lib/memdebug.c b/lib/memdebug.c
index 477ee43cfbb73ca352c3e906f6cb00b778db553d..dceb3bea93d228ac6d6caa0efdbc58dc91093d1c 100644
--- a/lib/memdebug.c
+++ b/lib/memdebug.c
@@ -45,6 +45,7 @@
 #include "urldata.h"
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 /*
  * Note that these debug functions are very simple and they are meant to