From e5cbd267c1a847b5d97ee97cd4a8f22e37dcd8b1 Mon Sep 17 00:00:00 2001 From: Arthur Hardy Bousquet Date: Wed, 9 May 2018 09:33:28 -0600 Subject: [PATCH] Added error if malloc fails on file load --- utp_com.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utp_com.c b/utp_com.c index 69e3cd9..6ce7bc8 100644 --- a/utp_com.c +++ b/utp_com.c @@ -195,6 +195,12 @@ int main(int argc, char * argv[]) // Allocate memory file_data = malloc(st.st_size); + if (file_data == 0) + { + fprintf(stderr, "Memory allocation failed; Please ensure your VM has at least 3GB of memory\n"); + return 1; + } + // Open file file_fd = open(file_name, O_RDONLY); if (file_fd < 0)