From: Michael D. Lowis Date: Mon, 21 Aug 2017 16:26:47 +0000 (-0400) Subject: Fixed some bad pointer accesses in job_finish routine X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=4fc6df39cf5a2c301ffe413c9e641b2c03939ef5;p=projs%2Ftide.git Fixed some bad pointer accesses in job_finish routine --- diff --git a/Makefile b/Makefile index b40135c..cee8450 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ clean: find . \( -name '*.gcno' -o -name '*.gcda' \) -delete $(RM) $(BINS) $(TEST_BINS) -install: all +install: mkdir -p $(PREFIX)/bin cp -f tcmd $(PREFIX)/bin cp -f tfetch $(PREFIX)/bin diff --git a/lib/exec.c b/lib/exec.c index 4fc33b6..b3e650a 100644 --- a/lib/exec.c +++ b/lib/exec.c @@ -145,10 +145,13 @@ static bool job_done(Job* job) { static Job* job_finish(Job* job) { Job* next = job->next; if (job->prev) { - job->prev->next = job->next; - job->next->prev = job->prev; + job->prev->next = next; + if (next) + next->prev = job->prev; } else { - JobList = job->next; + if (next) + next->prev = NULL; + JobList = next; } free(job->data); free(job); diff --git a/pickfile b/pickfile index f02e9d0..0334c35 100644 --- a/pickfile +++ b/pickfile @@ -6,4 +6,4 @@ fi export PICKTITLE="Pick File ($PWD)" file="$(find $1 -not -path '*/\.*' -type f | sed 's|^\./||' | pick)" -tide "$file" +tctl "$file" diff --git a/picktag b/picktag index 8de8787..cf8b5cc 100755 --- a/picktag +++ b/picktag @@ -15,7 +15,7 @@ usage(){ if [ "" == "$TAGFILE" ] || [ "" == "$ACTION" ]; then usage fi -ma + printtags(){ cat "$TAGFILE" | grep -v '^!' | cut -f1 | uniq } diff --git a/tctl.c b/tctl.c index 1c9d41f..8a44189 100644 --- a/tctl.c +++ b/tctl.c @@ -43,16 +43,16 @@ int main(int argc, char** argv) { Window win = win_byfile(path); if (!win) { - printf("edit(%s)\n", argv[i]); + fprintf(stderr, "edit(%s)\n", argv[i]); edit(argv[i]); } else if (last) { - printf("focus(%#x,%s)\n", (int)win, addr); + fprintf(stderr, "focus(%#x,%s)\n", (int)win, addr); focus_window(win, addr); } free(path); } - XFlush(X.display); + XFlush(X.display); return 0; } @@ -108,7 +108,7 @@ static void prop_set(Window win, char* propname, Atom type, int format, void* it static void edit(char* path) { if (fork() == 0) - execv("tide", (char*[]){ "tide", path, NULL }); + exit(execvp("tide", (char*[]){ "tide", path, NULL })); } static Window win_byfile(char* path) { @@ -119,25 +119,25 @@ static Window win_byfile(char* path) { } static void focus_window(Window w, char* addr) { - XEvent ev = {0}; - ev.xclient.type = ClientMessage; + XEvent ev = {0}; + ev.xclient.type = ClientMessage; ev.xclient.send_event = True; ev.xclient.message_type = XInternAtom(X.display, "_NET_ACTIVE_WINDOW", False); - ev.xclient.window = w; - ev.xclient.format = 32; + ev.xclient.window = w; + ev.xclient.format = 32; long mask = SubstructureRedirectMask | SubstructureNotifyMask; - XSendEvent(X.display, X.root, False, mask, &ev); + XSendEvent(X.display, X.root, False, mask, &ev); XMapRaised(X.display, w); - if (addr && *addr) - prop_set(w, "TIDE_COMM", XA_STRING, 8, addr, strlen(addr)); + if (addr && *addr) + prop_set(w, "TIDE_COMM", XA_STRING, 8, addr, strlen(addr)); XFlush(X.display); } void get_abspath(char* path, char** abspath, char** addr) { - path = stringdup(path); - char* faddr = strrchr(path, ':'); - if (faddr) *(faddr++) = '\0'; + path = stringdup(path); + char* faddr = strrchr(path, ':'); + if (faddr) *(faddr++) = '\0'; char* rpath = realpath(path, NULL); if (!rpath) rpath = path; - *abspath = rpath, *addr = faddr; + *abspath = rpath, *addr = faddr; }