summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-07-17 14:11:58 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-07-17 14:11:58 +0200
commit27967b17597a24e76f06871332d7a44eeb790a80 (patch)
tree4972820dc16ae5379dc75896edc98b5ae48e9e8f
parent264b636f2687ebc48743e895ccbf816898c136ed (diff)
downloadabrt-27967b17597a24e76f06871332d7a44eeb790a80.tar.gz
abrt-27967b17597a24e76f06871332d7a44eeb790a80.tar.xz
abrt-27967b17597a24e76f06871332d7a44eeb790a80.zip
prevent leaking buf in some cases
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--src/Daemon/CrashWatcher.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp
index 9b677079..e21d57a4 100644
--- a/src/Daemon/CrashWatcher.cpp
+++ b/src/Daemon/CrashWatcher.cpp
@@ -47,7 +47,8 @@ to_string( T x )
}
*/
-gboolean CCrashWatcher::handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointer daemon){
+gboolean CCrashWatcher::handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointer daemon)
+{
GIOError err;
char *buf = new char[INOTIFY_BUFF_SIZE];
gsize len;
@@ -56,8 +57,9 @@ gboolean CCrashWatcher::handle_event_cb(GIOChannel *gio, GIOCondition condition,
CCrashWatcher *cc = (CCrashWatcher*)daemon;
if (err != G_IO_ERROR_NONE)
{
- cc->Warning("Error reading inotify fd.");
- return FALSE;
+ cc->Warning("Error reading inotify fd.");
+ delete[] buf;
+ return FALSE;
}
/* reconstruct each event and send message to the dbus */
while (i < len)
@@ -67,7 +69,7 @@ gboolean CCrashWatcher::handle_event_cb(GIOChannel *gio, GIOCondition condition,
event = (struct inotify_event *) &buf[i];
if (event->len)
- name = &buf[i] + sizeof (struct inotify_event);
+ name = &buf[i] + sizeof (struct inotify_event);
i += sizeof (struct inotify_event) + event->len;
cc->Debug(std::string("Created file: ") + name);
@@ -114,9 +116,15 @@ gboolean CCrashWatcher::handle_event_cb(GIOChannel *gio, GIOCondition condition,
cc->Warning(e.what());
if (e.type() == EXCEP_FATAL)
{
+ delete[] buf;
return -1;
}
}
+ catch (...)
+ {
+ delete[] buf;
+ throw;
+ }
}
else
{