]> git.mdlowis.com Git - projs/tide.git/commitdiff
Fixed some bad pointer accesses in job_finish routine
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 21 Aug 2017 16:26:47 +0000 (12:26 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 21 Aug 2017 16:26:47 +0000 (12:26 -0400)
Makefile
lib/exec.c
pickfile
picktag
tctl.c

index b40135c3f3fa05d7547cc88580f5ed88e35a8646..cee84500b0b233874f21800ea5cbab1a8c4f5e67 100644 (file)
--- 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
index 4fc33b624eed3161113f9d586984daca6021998e..b3e650a6647582699fb0ba38190a3c17b0fca29e 100644 (file)
@@ -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);
index f02e9d060de42da067617fa2f94f226d6fbe0e7b..0334c3562101a8b55259c747a14128e2133d0afd 100644 (file)
--- 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 8de878776b8e2a92f9b4acd7198e0ec415181c4c..cf8b5cc9f369fa121a692110c62a8d727f9c4b7f 100755 (executable)
--- 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 1c9d41f951e18d880b2229f9df57cc4bbf5d111d..8a44189ce136dfd0b9eb78d38b1771fb1e25adc8 100644 (file)
--- 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;
 }