diff --git a/src/main.c b/src/main.c
index 2424d7a4ddae861db77b5c5cc52c23c6bfe7000f..e3be28e643e82a088a4eda107ae40a6e733e0d78 100644
--- a/src/main.c
+++ b/src/main.c
@@ -98,6 +98,7 @@ static void set_master(const char *file)
 {
   if( master_file_location != _master_location+CONSTANT_STRLEN(MASTER_COOKIE))
     free(master_file_location);
+#undef strdup /* We can't use dmalloc strdup before pike_memory is initialized. */
   master_file_location = strdup( file );
 }