Index: trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 488)
+++ trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 490)
@@ -221,5 +221,5 @@
       sprintf(prefix,"%s.",dp->d_name);
       
-      map* tmpMap=getMapFromMaps(m,"lenv",tmp1);
+      //map* tmpMap=getMapFromMaps(m,"lenv",tmp1);
       
       int res;
@@ -467,4 +467,5 @@
 	  fprintf(stderr,"Function %s error %s\n",r_inputs->value,errstr);
 #endif
+	  *eres=-1;
 	  return;
 	}
@@ -661,7 +662,7 @@
 #endif
 
-int runRequest(map* request_inputs)
+int runRequest(map** inputs)
 {
-
+  
 #ifndef USE_GDB
   (void) signal(SIGSEGV,sig_handler);
@@ -674,6 +675,6 @@
 
   map* r_inputs=NULL;
+  map* request_inputs=*inputs;
   maps* m=NULL;
-
   char* REQUEST=NULL;
   /**
@@ -788,6 +789,8 @@
   if(request_inputs==NULL || r_inputs==NULL){ 
     errorException(m, _("Parameter <request> was not specified"),"MissingParameterValue","request");
-    freeMap(&request_inputs);
-    free(request_inputs);
+    if(count(request_inputs)==1){
+      freeMap(&request_inputs);
+      free(request_inputs);
+    }
     freeMaps(&m);
     free(m);
@@ -871,5 +874,4 @@
 
   if(strncasecmp(REQUEST,"GetCapabilities",15)==0){
-    struct dirent *dp;
 #ifdef DEBUG
     dumpMap(r_inputs);
@@ -1622,16 +1624,17 @@
 #endif
 		  if(hai==0){
-		    key=(char*)malloc((1+strlen((char*)val))*sizeof(char));
-		    snprintf(key,1+strlen((char*)val),"%s",(char*)val);
+		    key=zStrdup((char*)val);
 		  }else{
-		    has=(char*)malloc((3+strlen((char*)val)+strlen(key))*sizeof(char));
+		    has=(char*)malloc((4+xmlStrlen(val)+strlen(key))*sizeof(char));
 		    if(has == NULL){
 		      return errorException(m, _("Unable to allocate memory."), "InternalError",NULL);
 		    }
-		    snprintf(has,(3+strlen((char*)val)+strlen(key)),"%s: %s",key,(char*)val);
+		    snprintf(has,(3+xmlStrlen(val)+strlen(key)),"%s: %s",key,(char*)val);
+		    free(key);
 #ifdef POST_DEBUG
 		    fprintf(stderr,"%s\n",has);
 #endif
 		  }
+		  xmlFree(val);
 		}
 		hInternetP.header=curl_slist_append(hInternetP.header, has);
@@ -1647,5 +1650,5 @@
 		  fprintf(stderr,"Body part found !!!\n",(char*)cur3->content);
 #endif
-		  char *tmp=new char[cgiContentLength];
+		  char *tmp=(char*)malloc(cgiContentLength+1*sizeof(char));
 		  memset(tmp,0,cgiContentLength);
 		  xmlNodePtr cur4=cur3->children;
@@ -1664,6 +1667,7 @@
 		    if(btmps!=NULL)
 		      sprintf(tmp,"%s",(char*)btmps);
+		    xmlFree(btmps);
+		    cur4=cur4->next;
 		    xmlFreeDoc(bdoc);
-		    cur4=cur4->next;
 		  }
 		  map *btmp=getMap(tmpmaps->content,"href");
@@ -1686,8 +1690,10 @@
 		      curl_slist_free_all(hInternetP.header);
 		    addToMap(tmpmaps->content,"value",tmpContent);
+		    free(tmpContent);
 #ifdef POST_DEBUG
 		    fprintf(stderr,"DL CONTENT : (%s)\n",tmpContent);
-#endif
+#endif		    
 		  }
+		  free(tmp);
 		}
 		else
@@ -1842,4 +1848,5 @@
 		  sprintf(size,"%d",buffersize);
 		  addToMap(tmpmaps->content,"size",size);
+		  xmlFreeDoc(doc1);
 		}
 		addToMap(tmpmaps->content,"value",(char*)mv);
@@ -2137,4 +2144,5 @@
     }
     xmlXPathFreeObject(tmpsptr);
+    xmlFreeDoc(doc);
     xmlCleanupParser();
   }
@@ -2168,5 +2176,5 @@
 	char tmps[1024];
 	map* tmpe=createMap("code","FileSizeExceeded");
-	snprintf(tmps,1024,_("The <%s> parameter has a limited size (%sMB) defined in ZOO ServicesProvider configuration file but the reference you provided exceed this limitation (%dMB), please correct your query or the ZOO Configuration file."),ptr->name,tmp1->value,i);
+	snprintf(tmps,1024,_("The <%s> parameter has a limited size (%sMB) defined in ZOO ServicesProvider configuration file but the reference you provided exceed this limitation (%fMB), please correct your query or the ZOO Configuration file."),ptr->name,tmp1->value,i);
 	addToMap(tmpe,"locator",ptr->name);
 	addToMap(tmpe,"text",tmps);
@@ -2230,5 +2238,4 @@
 	cgiFilePtr file;
 	int targetFile;
-	mode_t mode;
 	char storageNameOnServer[2048];
 	char fileNameOnServer[64];
@@ -2259,5 +2266,4 @@
 	  fprintf(stderr,"fileNameOnServer: %s\n",fileNameOnServer);
 #endif
-	  mode=S_IRWXU|S_IRGRP|S_IROTH;
 	  targetFile = open (storageNameOnServer,O_RDWR|O_CREAT|O_TRUNC,S_IRWXU|S_IRGRP|S_IROTH);
 	  if(targetFile<0){
@@ -2408,5 +2414,4 @@
     char *tcook=zStrdup(cgiCookie);
     char *tmp=NULL;
-    int hasVal=-1;
     map* testing=getMapFromMaps(m,"main","cookiePrefix");
     if(testing==NULL){
@@ -2415,5 +2420,4 @@
       tmp=(char*)malloc((strlen(testing->value)+2)*sizeof(char));
       sprintf(tmp,"%s=",testing->value);
-      hasVal=1;
     }
     if(strstr(cgiCookie,";")!=NULL){
@@ -2585,5 +2589,4 @@
   (void) signal(SIGABRT,donothing);
 #endif
-
   if(((int)getpid())!=cpid || cgiSid!=NULL){
     fclose(stdout);
@@ -2608,4 +2611,5 @@
     unlink(fbkp1);
     free(fbkp1);
+    free(tmps1);
   }
 
