From 88052c9d3dbe22c5ce16ea03dadd00d85ee03b56 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 31 Dec 2015 16:30:14 +0100 Subject: Fix a couple of errors detected by coverity. --- plugingui/directory.cc | 2 +- plugingui/nativewindow_x11.h | 14 +++++++------- plugingui/painter.cc | 1 + plugingui/plugingui.h | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/plugingui/directory.cc b/plugingui/directory.cc index c7a17b2..08bf59a 100644 --- a/plugingui/directory.cc +++ b/plugingui/directory.cc @@ -264,7 +264,7 @@ Directory::EntryList Directory::listFiles(std::string path, unsigned char filter entries.push_back(file); } - + closedir(dir); return entries; } diff --git a/plugingui/nativewindow_x11.h b/plugingui/nativewindow_x11.h index d7b3902..134ab6f 100644 --- a/plugingui/nativewindow_x11.h +++ b/plugingui/nativewindow_x11.h @@ -56,17 +56,17 @@ private: Event* translateXMessage(XEvent& xevent, bool peek = false); XImage* createImageFromBuffer(unsigned char* buf, int width, int height); - ::Window xwindow; - GC gc; - XImage* buffer; + ::Window xwindow{0}; + GC gc{0}; + XImage* buffer{nullptr}; Window& window; - int last_click; + int last_click{0}; - Display* display; - int screen; - Atom wmDeleteMessage; + Display* display{nullptr}; + int screen{0}; + Atom wmDeleteMessage{0}; }; } // GUI:: diff --git a/plugingui/painter.cc b/plugingui/painter.cc index a1c3f93..01fae5d 100644 --- a/plugingui/painter.cc +++ b/plugingui/painter.cc @@ -193,6 +193,7 @@ void Painter::drawText(int x0, int y0, const Font& font, // If the text offset is outside the buffer; skip it. if((x0 > (int)pixbuf->width) || (y0 > (int)pixbuf->height)) { + delete textbuf; return; } diff --git a/plugingui/plugingui.h b/plugingui/plugingui.h index bdb7da5..b57855a 100644 --- a/plugingui/plugingui.h +++ b/plugingui/plugingui.h @@ -63,10 +63,10 @@ public: void handleMessage(Message* msg); DGWindow* window{nullptr}; - EventHandler* eventhandler; + EventHandler* eventhandler{nullptr}; - Config* config; + Config* config{nullptr}; Notifier<> closeNotifier; -- cgit v1.2.3