diff options
author | Dmitrij D. Czarkoff <czarkoff@gmail.com> | 2015-12-28 11:59:52 +0100 |
---|---|---|
committer | Dmitrij D. Czarkoff <czarkoff@gmail.com> | 2015-12-28 11:59:52 +0100 |
commit | a70919c9caf23755e474c1364a8f838d75bc704e (patch) | |
tree | 45be05b2d304798fe9c766566a16bbeb69288364 /src | |
parent | c6096967e3d8d98f24210d4c66e4d22509bdce5c (diff) | |
download | imv-a70919c9caf23755e474c1364a8f838d75bc704e.tar.gz |
Add checks for malloc(3)
Exit(3) if memory allocation fails.
Diffstat (limited to 'src')
-rw-r--r-- | src/navigator.c | 9 |
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; |