Skip to content
Snippets Groups Projects
Commit 0ca7c752 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

clean stralloc treename and tree before using it

parent 68950c2a
No related branches found
No related tags found
No related merge requests found
......@@ -36,13 +36,15 @@ int tree_sethome(ssexec_t *info)
int r ;
if (!info->treename.len) {
if (!info->opt_tree) {
if (!tree_find_current(&info->tree, base))
if (!tree_find_current(&info->tree, base)) {
/** no current tree found. Use the default one. */
info->tree.len = 0 ;
if (!auto_stra(&info->tree, base, SS_SYSTEM, "/", SS_DEFAULT_TREENAME))
return 0 ;
}
info->treename.len = 0 ;
if (!tree_setname(&info->treename, info->tree.s))
return -2 ;
......@@ -57,17 +59,18 @@ int tree_sethome(ssexec_t *info)
return 0 ;
} else if (!r) {
/** Tree doesn't exist yet.
* Let see if we have a seed file to create it */
if (!tree_seed_isvalid(info->treename.s))
log_warnu_return(LOG_EXIT_ZERO,"find a seed file to create the tree: ", info->treename.s) ;
int nargc = 3 ;
int nargc = 4 ;
char const *newargv[nargc] ;
unsigned int m = 0 ;
newargv[m++] = "66 tree" ;
newargv[m++] = "66" ;
newargv[m++] = "tree" ;
newargv[m++] = info->treename.s ;
newargv[m++] = 0 ;
......@@ -77,6 +80,7 @@ int tree_sethome(ssexec_t *info)
log_warnu_return(LOG_EXIT_ZERO,"create tree: ",info->treename.s) ;
PROG = prog ;
}
/** The tree_sethome() function can be recursively called. The info->tree may not be empty.
* Be sure to clean up before using it. */
info->tree.len = 0 ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment