diff --git a/src/main.cpp b/src/main.cpp
index 57d09b9a00735c520893233b9da83ad210543b00..eb1d6c561ba5bee7c02902280e296c5c1939d09a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -37,7 +37,7 @@
 int main(int argc,char *argv[])
 {
 
-	Tango::Util *tg;
+	Tango::Util *tg = NULL;
 
 	Tango::Util::_daemon = true;
 	Tango::Util::_sleep_between_connect = 10;	
@@ -71,7 +71,9 @@ int main(int argc,char *argv[])
 		cout << "Received a CORBA_Exception" << endl;
 		cout << "Exiting" << endl;
 	}
-	tg->server_cleanup();
+  if (tg != NULL) {
+	  tg->server_cleanup();
+  }
 	return(0);
 }