From 484a7e3b2602fabcf0353dfe7e88be0458fa8e66 Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Tue, 12 Jul 2011 17:40:42 +0100 Subject: [PATCH 1/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 0ebaded..9e730e8 100644 --- a/bustle-dbus-monitor.c +++ b/bustle-dbus-monitor.c @@ -336,11 +336,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