ref: 127edcedd0467bdcb3e474f50b51867be20e0d84
parent: 848a598df06df0557bfe37dd6711d8ed966a56b6
author: phil9 <telephil9@gmail.com>
date: Mon Jan 24 05:48:56 EST 2022
ensure path parameter is a valid directory on startup vdir would crash if a wrong directory was passed as a parameter. We now make sure this is a valid directory or default to the current working directory. thanks qwx for the bug report.
--- a/vdir.c
+++ b/vdir.c
@@ -595,14 +595,13 @@
scrolling = 0;
oldbuttons = 0;
lastn = -1;
- getwd(path, sizeof path);
- if(argc==2)
+ if(getwd(path, sizeof path) == nil)
+ sysfatal("getwd: %r");
+ if(argc==2 && access(argv[1], 0) >= 0)
snprint(path, sizeof path, abspath(path, argv[1]));
plumbfd = plumbopen("send", OWRITE|OCEXEC);
if(plumbfd<0)
sysfatal("plumbopen: %r");
- readhome();
- loaddirs();
if(initdraw(nil, nil, "vdir")<0)
sysfatal("initdraw: %r");
display->locking = 0;
@@ -615,6 +614,8 @@
alts[Emouse].c = mctl->c;
alts[Eresize].c = mctl->resizec;
alts[Ekeyboard].c = kctl->c;
+ readhome();
+ loaddirs();
initcolors();
initimages();
evtresize();