Fix memleaks and a typo 44/13944/2
Calixte DENIZET [Thu, 6 Mar 2014 16:25:14 +0000 (17:25 +0100)]
Change-Id: I8b625ba343faeb8bf779b01d04fc7202295419e4

scilab/modules/atoms/macros/atomsGetConfig.sci
scilab/modules/fileio/src/c/dlManager.c
scilab/modules/preferences/src/c/getScilabPreference.c

index 3df5494..bc98b92 100644 (file)
@@ -80,7 +80,7 @@ function result = atomsGetConfig(field)
         config_lines = mgetl(atoms_directory + "config");
     else
         if (rhs == 0)
-            values = getPreferenceValue("//web/body/proxy", pref_attrs(2, :));
+            values = getPreferencesValue("//web/body/proxy", pref_attrs(2, :));
             for i = 1:size(pref_attrs, "c")
                 if ~isempty(values(i)) then
                     if values(i) == "true" then
index 5b58f6a..d26ddca 100644 (file)
@@ -318,6 +318,8 @@ char *downloadFile(char *url, char *dest, char *username, char *password, char *
             res = curl_easy_setopt(curl, CURLOPT_PROXY, proxyHost);
             if (res != CURLE_OK)
             {
+                FREE(proxyHost);
+                FREE(proxyUserPwd);
                 FREE(filename);
                 Scierror(999, _("Failed to set proxy host [%s]\n"), errorBuffer);
                 return NULL;
@@ -326,6 +328,8 @@ char *downloadFile(char *url, char *dest, char *username, char *password, char *
             res = curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxyPort);
             if (res != CURLE_OK)
             {
+                FREE(proxyHost);
+                FREE(proxyUserPwd);
                 FREE(filename);
                 Scierror(999, _("Failed to set proxy port [%s]\n"), errorBuffer);
                 return NULL;
@@ -335,12 +339,16 @@ char *downloadFile(char *url, char *dest, char *username, char *password, char *
                 res = curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, proxyUserPwd);
                 if (res != CURLE_OK)
                 {
+                    FREE(proxyHost);
+                    FREE(proxyUserPwd);
                     FREE(filename);
                     Scierror(999, _("Failed to set proxy user:password [%s]\n"), errorBuffer);
                     return NULL;
                 }
             }
 
+            FREE(proxyHost);
+            FREE(proxyUserPwd);
         }
     } /* end of the set of the proxy */
 
index 0c0e206..20cc955 100644 (file)
@@ -216,10 +216,11 @@ void getDocAndCtxt(xmlDocPtr * doc, xmlXPathContextPtr * xpathCtxt)
             FREE(shortfilename_xml_conf);
             shortfilename_xml_conf = NULL;
         }
-        FREE(path);
-        path = NULL;
     }
 
+    FREE(path);
+    path = NULL;
+
     if (*doc == NULL)
     {
         *xpathCtxt = NULL;
@@ -402,9 +403,10 @@ void setPrefAttributesValues(const char * xpath, const char ** kv, const unsigne
             FREE(shortfilename_xml_conf);
             shortfilename_xml_conf = NULL;
         }
-        FREE(path);
-        path = NULL;
     }
 
+    FREE(path);
+    path = NULL;
+
     xmlFreeDoc(doc);
 }