Browse Source

set_depth() checks for depth overflow

Serj Kalichev 6 years ago
parent
commit
40df3b1317
1 changed files with 4 additions and 1 deletions
  1. 4 1
      clish/shell/shell_view.c

+ 4 - 1
clish/shell/shell_view.c

@@ -56,9 +56,12 @@ unsigned int clish_shell__get_depth(const clish_shell_t *this)
 /*--------------------------------------------------------- */
 clish_view_t *clish_shell__set_depth(clish_shell_t *this, unsigned int depth)
 {
-	clish_view_t *tmp;
+	clish_view_t *tmp = NULL;
 
 	assert(this);
+	/* Overflow check */
+	if (depth >= this->pwdc)
+		return NULL;
 	/* Check if target view is valid = is not NULL */
 	tmp = this->pwdv[depth]->view;
 	if (!tmp)