Skip to content

Commit

Permalink
Fixing seg fault when deleting a directory from "Run command"
Browse files Browse the repository at this point in the history
* Now `show` will return the user to the last valid directory in the
history.
* Addresses bug #75
  • Loading branch information
roberthawdon committed Mar 2, 2019
1 parent 5884215 commit 923423a
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions src/showmenus.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,36 +277,45 @@ void refreshDirectory(char *sortmode, int origtopfileref, int origselected, int
{
char currentselectname[512];
int i;
if (invalidstart) {
strcpy(currentselectname, "");
exitCode = 0;
invalidstart = 0;
} else {
if (destructive == 2){
strcpy(currentselectname, currentfilename);
handleMissingDir:
if (check_dir(currentpwd)){
if (invalidstart) {
strcpy(currentselectname, "");
exitCode = 0;
invalidstart = 0;
} else {
strcpy(currentselectname, ob[origselected].name);
if (destructive == 2){
strcpy(currentselectname, currentfilename);
} else {
strcpy(currentselectname, ob[origselected].name);
}
}
}
if (destructive != -1){
free(ob);
ob = get_dir(currentpwd);
clear_workspace();
reorder_ob(ob, sortmode);
}
if (destructive > 0){
i = findResultByName(ob, currentselectname);
if (i != 0){
selected = i;
} else {
if (selected > totalfilecount - 1){
selected = totalfilecount - 1;
if (destructive != -1){
free(ob);
ob = get_dir(currentpwd);
clear_workspace();
reorder_ob(ob, sortmode);
}
if (destructive > 0){
i = findResultByName(ob, currentselectname);
if (i != 0){
selected = i;
} else {
selected = origselected;
if (selected > totalfilecount - 1){
selected = totalfilecount - 1;
} else {
selected = origselected;
}
}
} else {
selected = findResultByName(ob, currentselectname);
}
} else {
selected = findResultByName(ob, currentselectname);
strcpy(currentpwd, hs[historyref - 2].path);
objectWild = hs[historyref - 2].objectWild;
historyref--;
chdir(currentpwd);
goto handleMissingDir;
}
topfileref = sanitizeTopFileRef(origtopfileref);
display_dir(currentpwd, ob, topfileref, selected);
Expand Down

0 comments on commit 923423a

Please sign in to comment.