Code

Patches 3-11 from 488862 for a number of memleaks and allocation/deallocation issues.
authorJosh Andler <scislac@gmail.com>
Wed, 16 Dec 2009 21:27:19 +0000 (13:27 -0800)
committerJosh Andler <scislac@gmail.com>
Wed, 16 Dec 2009 21:27:19 +0000 (13:27 -0800)
src/bind/javabind.cpp
src/dom/util/ziptool.cpp
src/extension/dxf2svg/entities2elements.cpp
src/extension/internal/emf-win32-inout.cpp
src/extension/internal/odf.cpp
src/extension/internal/pdfinput/pdf-input.cpp
src/extension/internal/pdfinput/svg-builder.cpp
src/inkjar/jar.cpp
src/libcroco/cr-cascade.c

index f7022584f73624bfa6a28a9603369856afd9632d..6dc8c9a9bb2b24d1615c0f3abfbd1a03d57f2a5d 100644 (file)
@@ -1010,6 +1010,7 @@ bool JavaBinderyImpl::callStatic(int type,
             default:
                 {
                 err("Unknown value type: %d", v.getType());
+                delete [] jvals;
                 return false;
                 }
             }
@@ -1057,7 +1058,7 @@ bool JavaBinderyImpl::callStatic(int type,
             return false;
             }
         }
-    delete jvals;
+    delete [] jvals;
     String errStr = getException();
     if (errStr.size()>0)
         {
@@ -1131,6 +1132,7 @@ bool JavaBinderyImpl::callInstance(
             default:
                 {
                 err("Unknown value type: %d", v.getType());
+                delete [] jvals;
                 return false;
                 }
             }
@@ -1178,7 +1180,7 @@ bool JavaBinderyImpl::callInstance(
             return false;
             }
         }
-    delete jvals;
+    delete [] jvals;
     String errStr = getException();
     if (errStr.size()>0)
         {
index 40f456bd6c146da3ca011ef1e65a59edc54b4436..1e915ab0a4160fcdb31b16ddcf117d89ce2cf776 100644 (file)
@@ -2207,6 +2207,7 @@ ZipEntry *ZipFile::addFile(const std::string &fileName,
     ZipEntry *ze = new ZipEntry();
     if (!ze->readFile(fileName, comment))
         {
+        delete ze;
         return NULL;
         }
     entries.push_back(ze);
index cf42dac32f406483177b29fb8f81dedeb6bf912f..ab160e2653de38561a92ce9952ac462a761a42b9 100644 (file)
@@ -80,7 +80,7 @@ void pline2svg(polyline pline, int type, int precision, char * units, double sca
        // 2 is pline2polygon
        
        
-       char delim[1];
+       char delim[2];
        double mag_bulge = 0;
        double prev_mag_bulge = 0;
        
@@ -185,7 +185,7 @@ void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double
        // 2 is pline2polygon
        
        
-       char delim[1];
+       char delim[2];
        double mag_bulge = 0;
        double prev_mag_bulge = 0;
        
index f400a36497008c5da1080c66f3c81cd6f5e13b21..9d25f3a7f17bba28443e4e6b7bd78b8eff7f8cc5 100644 (file)
@@ -127,6 +127,7 @@ emf_print_document_to_file(SPDocument *doc, gchar const *filename)
     /* Print document */
     ret = mod->begin(doc);
     if (ret) {
+        g_free(oldoutput);
         throw Inkscape::Extension::Output::save_failed();
     }
     sp_item_invoke_print(mod->base, &context);
index cc8489302d2c73da43173e14eba0be3fc2a49f19..46e0361ce5740941dc444a00dfa0f66fe675ad8d 100644 (file)
@@ -795,8 +795,8 @@ void SingularValueDecomposition::calculate()
          }
       }
 
-    delete e;
-    delete work;
+    delete [] e;
+    delete [] work;
 
 }
 
index c2d417f2c03d750dbcb3e54983fab76f92aca3d8..ba00fe3435e82bcadeedac8c6ee42f32afaed8bb 100644 (file)
@@ -734,6 +734,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
     delete builder;
     g_free(docname);
     delete pdf_doc;
+    delete dlg;
 
     // Restore undo
     sp_document_set_undo_sensitive(doc, saved);
index 00bd8fa4d8df9e00b2f09492381cd60b99cdd275..b9583545fb3ed237f0b336769b625aa775e5f11f 100644 (file)
@@ -1536,7 +1536,7 @@ Inkscape::XML::Node *SvgBuilder::_createImage(Stream *str, int width, int height
             }
             png_write_row(png_ptr, (png_bytep)buffer);
         }
-        delete buffer;
+        delete [] buffer;
     } else if (color_map) {
         image_stream = new ImageStream(str, width,
                                        color_map->getNumPixelComps(),
@@ -1575,7 +1575,7 @@ Inkscape::XML::Node *SvgBuilder::_createImage(Stream *str, int width, int height
                 png_write_row(png_ptr, (png_bytep)buffer);
             }
         }
-        delete buffer;
+        delete [] buffer;
 
     } else {    // A colormap must be provided, so quit
         png_destroy_write_struct(&png_ptr, &info_ptr);
index d53901de5be5b67e4b7f7d460ab4df294ce83d5f..6897cb317de0fe0ab9e45eec444159e484f39951 100644 (file)
@@ -66,7 +66,7 @@ namespace Inkjar {
 
 JarFile::JarFile(gchar const*new_filename)
 {
-    _filename = strdup(new_filename);
+    _filename = g_strdup(new_filename);
     _last_filename = NULL;
     fd = -1;
 }
@@ -75,7 +75,7 @@ JarFile::JarFile(gchar const*new_filename)
 //       use strdup
 gchar *JarFile::get_last_filename() const
 {
-    return (_last_filename != NULL ? strdup(_last_filename) : NULL);
+    return (_last_filename != NULL ? g_strdup(_last_filename) : NULL);
 }
 
 JarFile::~JarFile()
@@ -445,11 +445,11 @@ JarFile& JarFile::operator=(JarFile const& rhs)
     if (_filename == NULL)
        _filename = NULL;
     else
-       _filename = strdup(rhs._filename);
+       _filename = g_strdup(rhs._filename);
     if (_last_filename == NULL)
        _last_filename = NULL;
     else 
-       _last_filename = strdup(rhs._last_filename);
+       _last_filename = g_strdup(rhs._last_filename);
     fd = rhs.fd;
     
     return *this;
index f389fc746af756533f509cdfc098ad56dee7eaa5..7fef86c4a3516773fc02644558d3b37654c82f80 100644 (file)
@@ -70,6 +70,7 @@ cr_cascade_new (CRStyleSheet * a_author_sheet,
 
         PRIVATE (result) = (CRCascadePriv *)g_try_malloc (sizeof (CRCascadePriv));
         if (!PRIVATE (result)) {
+                g_free(result);
                 cr_utils_trace_info ("Out of memory");
                 return NULL;
         }