[Spice-devel] [PATCH 01/30] Fix delete vs delete[] mismatches

Alexander Larsson alexl at redhat.com
Thu Feb 18 12:58:27 PST 2010


This fixes a bunch of valgrind warnings.
---
 client/glz_decoder_window.cpp   |    4 ++--
 client/x11/red_pixmap_cairo.cpp |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/client/glz_decoder_window.cpp b/client/glz_decoder_window.cpp
index 9cd64ab..aca2485 100644
--- a/client/glz_decoder_window.cpp
+++ b/client/glz_decoder_window.cpp
@@ -50,7 +50,7 @@ GlzDecoderWindow::GlzDecoderWindow(int pixels_capacity, GlzDecoderDebug &debug_c
 GlzDecoderWindow::~GlzDecoderWindow()
 {
     clear();
-    delete _images;
+    delete[] _images;
 }
 
 DecodedImageWinId GlzDecoderWindow::pre_decode(uint64_t image_id, uint64_t relative_head_id)
@@ -246,7 +246,7 @@ void GlzDecoderWindow::realloc(int size)
     for (int i = 0; i < _n_images; i++) {
         new_images[i] = _images[(i + _head_idx) % _images_capacity];
     }
-    delete _images;
+    delete[] _images;
 
     _images = new_images;
     _head_idx = 0;
diff --git a/client/x11/red_pixmap_cairo.cpp b/client/x11/red_pixmap_cairo.cpp
index 795c8a0..7ca9315 100644
--- a/client/x11/red_pixmap_cairo.cpp
+++ b/client/x11/red_pixmap_cairo.cpp
@@ -181,7 +181,7 @@ RedPixmapCairo::~RedPixmapCairo()
     cairo_destroy(((RedDrawable_p*)get_opaque())->cairo);
     if (((PixelsSource_p*)get_opaque())->type == PIXELS_SOURCE_TYPE_PIXMAP) {
         delete ((PixelsSource_p*)get_opaque())->pixmap.x_image;
-        delete _data;
+        delete[] _data;
     } else {
         XShmSegmentInfo *shminfo = ((PixelsSource_p*)get_opaque())->x_shm_drawable.shminfo;
         XShmDetach(XPlatform::get_display(), shminfo);
-- 
1.6.6



More information about the Spice-devel mailing list