From ce8d4ebe0cfa7904ae83c7602a107ffb9469c6b9 Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Tue, 12 Jul 2011 17:40:42 +0100 Subject: [PATCH 2/3] fix an OOM situation --- bustle-dbus-monitor.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bustle-dbus-monitor.c b/bustle-dbus-monitor.c index 3b9326d..c428d65 100644 --- a/bustle-dbus-monitor.c +++ b/bustle-dbus-monitor.c @@ -346,11 +346,15 @@ main (int argc, char *argv[]) else if (arg[0] == '-') usage (argv[0], 1); else { - numFilters++; - filters = (char **)realloc(filters, numFilters * sizeof(char *)); - filters[j] = (char *)malloc((strlen(arg) + 1) * sizeof(char *)); - snprintf(filters[j], strlen(arg) + 1, "%s", arg); - j++; + numFilters++; + filters = (char **) realloc (filters, numFilters * sizeof (char *)); + if (filters == NULL) + oom ("(re)creating filter slots"); + filters[j] = (char *) malloc ((strlen (arg) + 1) * sizeof (char *)); + if (filters[j] == NULL) + oom ("creating filter"); + snprintf (filters[j], strlen(arg) + 1, "%s", arg); + j++; } } -- 1.7.5.4