--- a/lib/master.c	2013-02-13 05:31:08.000000000 +1300
+++ b/lib/master.c	2014-05-27 11:58:15.000000000 +1200
@@ -60,6 +60,11 @@ void ec_master_clear_config(ec_master_t
     ec_domain_t *d, *next_d;
     ec_slave_config_t *c, *next_c;
 
+    if (master->process_data)  {
+        munmap(master->process_data, master->process_data_size);
+        master->process_data = NULL;
+    }
+
     d = master->first_domain;
     while (d) {
         next_d = d->next;
@@ -81,10 +86,6 @@ void ec_master_clear_config(ec_master_t
 
 void ec_master_clear(ec_master_t *master)
 {
-    if (master->process_data)  {
-        munmap(master->process_data, master->process_data_size);
-    }
-
     ec_master_clear_config(master);
 
     if (master->fd != -1) {
