Aleš Erjavec avatar Aleš Erjavec committed 57399ad

Fixed two memory leaks.

Comments (0)

Files changed (2)

source/orange/cls_orange.cpp

     if ((*name >= 'A') && (*name <= 'Z')) {
       *name ^= 32;
       }
-    return PyString_FromString(name);
+
+    PyObject * orangename = PyString_FromString(name);
+    free(name);
+
+    return orangename;
+
   PyCATCH
 }
 

source/orange/lib_kernel.cpp

   for(const char *pi = path, *pe=pi; *pi; pi = pe+1) {
     for(pe = pi; *pe && *pe != sep; pe++);
     const int plen = pe-pi;
-    char *npath = strncpy(new char[plen+flen+2], pi, pe-pi);
+    char *npath = new char[plen + flen + 2];
+    strncpy(npath, pi, pe - pi);
     if (!plen || (pi[plen] != pathsep)) {
       npath[plen] = pathsep;
       strcpy(npath+plen+1, filename);
       strcpy(npath+plen, filename);
     }
     PyObject *res = loadDataFromFileNoSearch(type, npath, argstuple, keywords, generatorOnly);
+    delete[] npath;
+
     PyErr_Clear();
     if (res) {
       return res;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.