summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2009-07-18 00:28:27 +0200
committerTobias Klauser <tklauser@distanz.ch>2009-07-18 00:28:27 +0200
commitf94983728ebaf1a6272e4f47977d09236cdd25c3 (patch)
tree7c3e029b5edcd6c486343b5d7c5154afeb6aa340
parent256053718479dfce4d8469dea1cd66bb17842509 (diff)
direct-append: Check return value of malloc
-rw-r--r--direct-append.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/direct-append.c b/direct-append.c
index af7efb4..2b782ff 100644
--- a/direct-append.c
+++ b/direct-append.c
@@ -61,6 +61,10 @@ int main(int argc, char *argv[])
}
str = malloc(n_chars * sizeof(char));
+ if (!str) {
+ perror("malloc");
+ exit(EXIT_FAILURE);
+ }
for (i = 0; i < n_chars; i++)
str[i] = get_random_printable_char();