calc.c: Fix path display when scanning an empty directory

http://dev.yorhel.nl/ncdu/bug/15
This commit is contained in:
Yorhel 2012-08-18 09:21:33 +02:00
parent 832b91b033
commit 399ccdeb47

View file

@ -458,11 +458,6 @@ int calc_process() {
/* calculate */ /* calculate */
n = calc_dir(root, name); n = calc_dir(root, name);
/* free some resources */
if(!path[1] && strcmp(name, "."))
free(name);
free(path);
if(links) { if(links) {
kh_destroy(hl, links); kh_destroy(hl, links);
links = NULL; links = NULL;
@ -473,6 +468,7 @@ int calc_process() {
if(root->sub == NULL) { if(root->sub == NULL) {
freedir(root); freedir(root);
failed = 1; failed = 1;
calc_enterpath(name);
strcpy(errmsg, "Directory empty."); strcpy(errmsg, "Directory empty.");
goto calc_fail; goto calc_fail;
} }
@ -498,6 +494,10 @@ int calc_process() {
/* something went wrong... */ /* something went wrong... */
freedir(root); freedir(root);
calc_fail: calc_fail:
if(!path[1] && strcmp(name, "."))
free(name);
free(path);
while(failed && !input_handle(0)) while(failed && !input_handle(0))
; ;
if(orig == NULL) if(orig == NULL)