aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/sha-2
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-01-22 18:35:57 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-01-22 18:35:57 +0100
commitfbcbdb2585263ab5156660347bbe6ad3376221a0 (patch)
treeeec4e9faf56bcfd9ca5183970d58773ea29b6f46 /test/monniaux/sha-2
parent5add9bc1c53b5796e23fe3e418846241a695886a (diff)
downloadcompcert-kvx-fbcbdb2585263ab5156660347bbe6ad3376221a0.tar.gz
compcert-kvx-fbcbdb2585263ab5156660347bbe6ad3376221a0.zip
check malloc() return values
Diffstat (limited to 'test/monniaux/sha-2')
-rw-r--r--test/monniaux/sha-2/sha-256_run.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/test/monniaux/sha-2/sha-256_run.c b/test/monniaux/sha-2/sha-256_run.c
index 5b5031c3..68fbcd3e 100644
--- a/test/monniaux/sha-2/sha-256_run.c
+++ b/test/monniaux/sha-2/sha-256_run.c
@@ -135,6 +135,15 @@ static struct vector vectors[] = {
#endif
};
+static void *my_malloc(size_t size) {
+ void *p=malloc(size);
+ if (p==0) {
+ fprintf(stderr, "malloc(%zu) failed\n", size);
+ abort();
+ }
+ return p;
+}
+
static void construct_binary_messages(void)
{
memset(data7, 0x00, sizeof data7);
@@ -145,9 +154,9 @@ static void construct_binary_messages(void)
* Heap allocation as a workaround for some linkers not liking
* large BSS segments.
*/
- data11 = malloc(SIZEOF_DATA11);
- data12 = malloc(SIZEOF_DATA12);
- data13 = malloc(SIZEOF_DATA13);
+ data11 = my_malloc(SIZEOF_DATA11);
+ data12 = my_malloc(SIZEOF_DATA12);
+ data13 = my_malloc(SIZEOF_DATA13);
memset(data11, 0x5a, SIZEOF_DATA11);
memset(data12, 0x00, SIZEOF_DATA12);
memset(data13, 0x42, SIZEOF_DATA13);