From: Josh Andler Date: Wed, 16 Dec 2009 21:27:19 +0000 (-0800) Subject: Patches 3-11 from 488862 for a number of memleaks and allocation/deallocation issues. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=dc7a7dae1757af28215a38f4b71ef84776b38f6c;p=inkscape.git Patches 3-11 from 488862 for a number of memleaks and allocation/deallocation issues. --- diff --git a/src/bind/javabind.cpp b/src/bind/javabind.cpp index f7022584f..6dc8c9a9b 100644 --- a/src/bind/javabind.cpp +++ b/src/bind/javabind.cpp @@ -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) { diff --git a/src/dom/util/ziptool.cpp b/src/dom/util/ziptool.cpp index 40f456bd6..1e915ab0a 100644 --- a/src/dom/util/ziptool.cpp +++ b/src/dom/util/ziptool.cpp @@ -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); diff --git a/src/extension/dxf2svg/entities2elements.cpp b/src/extension/dxf2svg/entities2elements.cpp index cf42dac32..ab160e265 100644 --- a/src/extension/dxf2svg/entities2elements.cpp +++ b/src/extension/dxf2svg/entities2elements.cpp @@ -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; diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index f400a3649..9d25f3a7f 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -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); diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index cc8489302..46e0361ce 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -795,8 +795,8 @@ void SingularValueDecomposition::calculate() } } - delete e; - delete work; + delete [] e; + delete [] work; } diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index c2d417f2c..ba00fe343 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -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); diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 00bd8fa4d..b9583545f 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -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); diff --git a/src/inkjar/jar.cpp b/src/inkjar/jar.cpp index d53901de5..6897cb317 100644 --- a/src/inkjar/jar.cpp +++ b/src/inkjar/jar.cpp @@ -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; diff --git a/src/libcroco/cr-cascade.c b/src/libcroco/cr-cascade.c index f389fc746..7fef86c4a 100644 --- a/src/libcroco/cr-cascade.c +++ b/src/libcroco/cr-cascade.c @@ -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; }