From a70919c9caf23755e474c1364a8f838d75bc704e Mon Sep 17 00:00:00 2001
From: "Dmitrij D. Czarkoff" <czarkoff@gmail.com>
Date: Mon, 28 Dec 2015 11:59:52 +0100
Subject: Add checks for malloc(3)

Exit(3) if memory allocation fails.
---
 src/navigator.c | 9 +++++++++
 1 file changed, 9 insertions(+)

(limited to 'src')

diff --git a/src/navigator.c b/src/navigator.c
index bd049c5..143d28b 100644
--- a/src/navigator.c
+++ b/src/navigator.c
@@ -27,7 +27,16 @@ void imv_navigator_init(struct imv_navigator *nav)
 {
   nav->buf_size = 512;
   nav->paths = malloc(sizeof(char*) * nav->buf_size);
+  if (nav->paths == NULL) {
+    perror("imv_navigator_init");
+    exit(1);
+  }
   nav->mtimes = malloc(sizeof(time_t) * nav->buf_size);
+  if (nav->paths == NULL) {
+    perror("imv_navigator_init");
+    free(nav->paths);
+    exit(1);
+  }
   nav->num_paths = 0;
   nav->cur_path = 0;
   nav->last_move_direction = 1;
-- 
cgit v1.2.3