aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitrij D. Czarkoff <czarkoff@gmail.com>2015-12-28 11:59:52 +0100
committerDmitrij D. Czarkoff <czarkoff@gmail.com>2015-12-28 11:59:52 +0100
commita70919c9caf23755e474c1364a8f838d75bc704e (patch)
tree45be05b2d304798fe9c766566a16bbeb69288364 /src
parentc6096967e3d8d98f24210d4c66e4d22509bdce5c (diff)
downloadimv-a70919c9caf23755e474c1364a8f838d75bc704e.tar.gz
Add checks for malloc(3)
Exit(3) if memory allocation fails.
Diffstat (limited to 'src')
-rw-r--r--src/navigator.c9
1 files changed, 9 insertions, 0 deletions
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;