summaryrefslogtreecommitdiff
blob: f609da19d05f3832fa025c3efe051d5ff6bb8f7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Make sure the malloc's work.

http://bugs.gentoo.org/91977

--- eject.c
+++ eject.c
@@ -304,2 +304,11 @@
 
+void *xmalloc(size_t size)
+{
+	void *ret = malloc(size);
+	if (!ret) {
+		fprintf(stderr, _("%s: could not allocate memory\n"), programName);
+		exit(1);
+	}
+	return ret;
+}
 
@@ -324,3 +333,3 @@
 
-	buf = (char *) malloc(strlen(name)+14); /* to allow for "/dev/cdroms/ + "0" + null */
+	buf = (char *) xmalloc(strlen(name)+14); /* to allow for "/dev/cdroms/ + "0" + null */
 
@@ -794,3 +803,3 @@
 		if (status == 0) {
-			result = (char *) malloc(strlen(name) + 25);
+			result = (char *) xmalloc(strlen(name) + 25);
 			strcpy(result, name);