summaryrefslogtreecommitdiff
path: root/c-sources
diff options
context:
space:
mode:
authorCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2011-07-12 17:40:42 +0100
committerWill Thompson <will@willthompson.co.uk>2012-01-13 11:30:25 +0000
commit5cbf70f1e15516d3632a130a945988c9c1ae6ec2 (patch)
tree8f154b06b376017ca3e514b1893674f888d1bde7 /c-sources
parente74a8cec3421d8712e1132c0851e862d86b1a51c (diff)
fix an OOM situation
Diffstat (limited to 'c-sources')
-rw-r--r--c-sources/bustle-dbus-monitor.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/c-sources/bustle-dbus-monitor.c b/c-sources/bustle-dbus-monitor.c
index 0ebaded..9e730e8 100644
--- a/c-sources/bustle-dbus-monitor.c
+++ b/c-sources/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++;
}
}