[Cluster-devel] [PATCH cluster 4/5] dlm/tests: handle malloc failure
Jim Meyering
jim at meyering.net
Tue Jun 23 11:44:09 UTC 2009
From: Jim Meyering <meyering at redhat.com>
* dlm/tests/usertest/flood.c (main): Handle malloc failure.
---
dlm/tests/usertest/flood.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlm/tests/usertest/flood.c b/dlm/tests/usertest/flood.c
index efe3a4b..c01bc0d 100644
--- a/dlm/tests/usertest/flood.c
+++ b/dlm/tests/usertest/flood.c
@@ -112,7 +112,11 @@ int main(int argc, char *argv[])
}
}
- resources = malloc(sizeof(char*) * rescount);
+ if ((resources = malloc(sizeof(char*) * rescount)) == NULL)
+ {
+ perror("exhausted virtual memory");
+ return 1;
+ }
for (i=0; i < rescount; i++) {
char resname[256];
sprintf(resname, "TESTLOCK%d", i);
@@ -164,4 +168,3 @@ int main(int argc, char *argv[])
return 0;
}
-
--
1.6.3.3.420.gd4b46
More information about the Cluster-devel
mailing list